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?


1 Answer 1


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 hosts file.

  • Could anyone exapnd this answer with an example or make it more detailed?
    – xliiv
    Commented May 16, 2018 at 11:10
  • 1
    @xliiv here's some tutorial: dtbaker.net/blog/… - you'd have to change subnets to your own in IPTABLES commands' parameters and add appropriate entries to hosts file (which is pretty straightforward).
    – carbolymer
    Commented Jun 1, 2020 at 13:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .