Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to add the same port to use different upstream #395

Open
liang-hiwin opened this issue Jun 22, 2024 · 10 comments
Open

Request to add the same port to use different upstream #395

liang-hiwin opened this issue Jun 22, 2024 · 10 comments

Comments

@liang-hiwin
Copy link

liang-hiwin commented Jun 22, 2024

for example:

[listeners.local-dtls]
address = ":853"
server = "block.example.com"
protocol = "dtls"
resolver = "Blockads-cloudflare-dot"           #####Block ads upstream
server-crt = "example-config/server-ec.crt"
server-key = "example-config/server-ec.key"
[listeners.local-dtls]
address = ":853"
server = "no-block.example.com"
protocol = "dtls"
resolver = "no_blockads-cloudflare-dot"           #####Do not block ads and directly forward requests to upstream
server-crt = "example-config/server-ec.crt"
server-key = "example-config/server-ec.key"
@folbricht
Copy link
Owner

I don't think it's possible exactly like in the example. Though what you should be able to do is setup different interfaces, and then have a listener on each.

@liang-hiwin
Copy link
Author

I don't think it's possible exactly like in the example. Though what you should be able to do is setup different interfaces, and then have a listener on each.

I want to use the same port and then decide which upstream to use depending on the domain name

@folbricht
Copy link
Owner

You can do that much more easily with a single listener that receives the query, then either a router or a blocklist behind it to send it upstream to the right place

@liang-hiwin
Copy link
Author

I still don't quite understand how to distinguish them. For example, if I build the dns-over-tls server: no-block.example.com:853, the upstream is clean and does not block ads. However, the upstream of the dns-over-tls server block.example.com:853 with ads removed is the upstream after ads are removed. I don't know how to configure it now.

@folbricht
Copy link
Owner

Hmm, if you want to have two different listeners on the same host with the client being able to choose, you could setup 2 different interfaces (with different IPs) on the host. So basically address = "<IP1>:853" and address = "<IP2>:853". Then set no-block.example.com -> IP1 and block.example.com -> IP2 to resolve the right IP.

@liang-hiwin
Copy link
Author

Hmm, if you want to have two different listeners on the same host with the client being able to choose, you could setup 2 different interfaces (with different IPs) on the host. So basically address = "<IP1>:853" and address = "<IP2>:853". Then set no-block.example.com -> IP1 and block.example.com -> IP2 to resolve the right IP.

I only have one public IP address for the same host, so it’s a bit difficult.

@folbricht
Copy link
Owner

With DoH it would be possible to do something like that (not implemented yet though), since the HTTP headers which contain the name the client used would be available to the listener.

@liang-hiwin
Copy link
Author

With DoH it would be possible to do something like that (not implemented yet though), since the HTTP headers which contain the name the client used would be available to the listener.

Yes doh I can do this using nginx

@cbuijs
Copy link
Contributor

cbuijs commented Jun 24, 2024

This should work:

[listeners.local-dtls]
address = ":853"
protocol = "dtls"
resolver = "route-queries"
server-crt = "example-config/server-ec.crt"
server-key = "example-config/server-ec.key"

[router.route-queries]
routes = [
    {servername = '^block\.', resolver = "Blockads-cloudflare-dot"},
    {servername = '^no-block\.', resolver = "no_blockads-cloudflare-dot"},
]

Not sure it works with dtls but it does with dot, and doq queries (I use it).

P.S. Make sure your certicate used, have both domains/servernames in it.

@liang-hiwin
Copy link
Author

853

Thanks for taking the time to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants