Created
November 3, 2025 22:49
-
-
Save williamzujkowski/8749d27f31c0c222e79033fc978069bd to your computer and use it in GitHub Desktop.
DoH Advanced Routing - nginx load balancing and geo-based provider selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # DoH Provider Selection Based on Geographic Location | |
| def select_doh_provider(client_ip): | |
| """Select optimal DoH provider based on location""" | |
| # Simplified geo-detection | |
| if client_ip.startswith('192.168.'): | |
| return "https://local-doh.home.arpa/dns-query" | |
| elif is_asian_ip(client_ip): | |
| return "https://dns.google/dns-query" # Better in Asia | |
| else: | |
| return "https://cloudflare-dns.com/dns-query" # Global default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # nginx DoH Load Balancing Configuration | |
| upstream doh_providers { | |
| server 1.1.1.1:443 weight=3; | |
| server dns.google:443 weight=2; | |
| server dns.quad9.net:443 weight=1; | |
| keepalive 32; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment