Server Routing based on the `Host` header
Open
Nobody has claimed this yet.
enhancement
need more information
- Dominant language
- Go
- Stars
- 38.1k
- Forks
- 4.6k
- Avg merge
- 19d 15h
- Merged PRs (30d)
- 1
Description
Can you please add server routing based on the Host header?
It is very helpful in terms of routing to custom outbounds using only a single port and a single inbound.
Example:
Client 1
{
"outbounds": [
{
"tag": "proxy",
"type": "trojan",
"server": "x.x.x.x",
"server_port": 443,
"password": "xxx",
"tls": {
"enabled": true,
"server_name": "speedtest.com",
"reality": {
"enabled": true,
"public_key": "xxx",
"short_id": "xxx"
},
"utls": {
"enabled": true,
"fingerprint": "firefox"
}
},
"transport": {
"type": "httpupgrade",
"host": "cdn-us.domain.com" <--------------1-----------------
}
}
]
}
Client 2
{
"outbounds": [
{
"tag": "proxy",
"type": "trojan",
"server": "x.x.x.x",
"server_port": 443,
"password": "xxx",
"tls": {
"enabled": true,
"server_name": "speedtest.com",
"reality": {
"enabled": true,
"public_key": "xxx",
"short_id": "xxx"
},
"utls": {
"enabled": true,
"fingerprint": "firefox"
}
},
"transport": {
"type": "httpupgrade",
"host": "cdn-de.domain.com" <--------------2-----------------
}
}
]
}
Server Config
{
"inbounds": [
{
"type": "trojan",
"tag": "trojan-in",
"listen": "0.0.0.0",
"listen_port": 443,
"users": [
{
"name": "user1@test",
"password": "xxx"
}
],
"tls": {
"enabled": true,
"server_name": "speedtest.com",
"reality": {
"enabled": true,
"handshake": {
"server": "speedtest.com",
"server_port": 443
},
"private_key": "xxx",
"short_id": "xxx"
}
},
"transport": {
"type": "httpupgrade",
"host": [
"cdn-us.domain.com", <--------------1----------------
"cdn-de.domain.com" <--------------2----------------
]
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"tag": "cdn-us",
"type": "socks",
"server": "x.x.x.x",
"server_port": 1080,
"version": "5"
},
{
"tag": "cdn-de",
"type": "socks",
"server": "y.y.y.y",
"server_port": 1080,
"version": "5"
}
],
"route": {
"rules": [
{
"action": "sniff",
"timeout": "5ms"
},
{
"action": "hijack-dns",
"protocol": "dns"
},
{
"action": "resolve",
"strategy": "ipv4_only"
},
{
"host": "cdn-us.domain.com", <--------------1----------------
"action": "route",
"outbound": "cdn-us"
},
{
"host": "cdn-de.domain.com", <--------------2----------------
"action": "route",
"outbound": "cdn-de"
}
]
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the server transport's HTTPUpgrade host values and route rules are parsed and applied. Compare the two client host values with the server configuration; done means a single inbound can distinguish those hosts and route each to its corresponding outbound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100