Search code examples
linuxproxysocks

Proxy only for some domains


Is there a possibility to configure proxy (global or for few processes) only for one domain (and its subdomains)?

What I'd like to achieve: All connections (HTTP/HTTPS, database connections, etc) to the subdomains of dupa.xyz should go through a proxy, connections to other domains should be direct. I know that I can define all_proxy and a long exclusion list using no_proxy environment variables, but I don't feel that it is the right way.

Is there maybe a third party application which provides this functionality?


Solution

  • Ok, I've found a solution. In my case all subdomains from dupa.xyz are in the same subnetwork, so the easiest solution is to use IPTABLES + redsocks + ssh tunnel to the host inside this subnetwork. In theory, it should be possible to redirect DNS traffic via TCP through redsocks, but I didn't try that. I've just added appropiate entries to the hosts file.