carbolymer carbolymer - 1 year ago 50
Linux Question

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
should go through a proxy, connections to other domains should be direct. I know that I can define
and a long exclusion list using
environment variables, but I don't feel that it is the right way.

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

Answer Source

Ok, I've found a solution. In my case all subdomains from 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.