0

I'm trying to make NginX or HAProxy use proxies while connecting to upstream URLs, something like this:

Browser -> Nginx/HAProxy -- SOCKS5 Tunnel --> Remote

I wonder if it's possible?

Edited:

Basically I would like to transparently proxy http requests:

  1. Set up a local DNS resolver (e.g. unbound) and rewrite DNS entries pointing some domains to localhost;

  2. NginX/HAProxy handles http requests based on their Host field (I'm also running a HTTP server) and proxies HTTP requests accordingly.

It would be quite useful to provide access to blocked domains without too many configurations on client side (especially in a Docker container, it would be rather difficult if it's an official image).

skies457
  • 21
  • 1
  • 5
  • Any reason to use socks5 in particular? Vs, say, an ssh tunnel or iptables-based port forward? Then you don't have to use proxy logic at the nginx/haproxy level to support SOCKS. Maybe you could say a little more about your use case – erik258 Jan 05 '17 at 15:22
  • @DanFarrell I've edited the question and added some more details. I wonder if it's possible to do this? – skies457 Jan 05 '17 at 15:32
  • Is your real question about accessing "blocked domains"? – erik258 Jan 05 '17 at 15:34
  • @DanFarrell Since I'm already able to bypass restrictions through the SOCKS5 proxy, I'm curious if I could do it transparently (just by setting up a DNS resolver on a Docker host) – skies457 Jan 05 '17 at 16:09
  • You'll need to either implement the feature in nginx/haproxy as module or use something like this https://github.com/normanr/socks-tun. – Florin Asăvoaie Jan 05 '17 at 16:22

1 Answers1

1

End up with a pure port forwarding solution instead of HAProxy or NginX. If anyone happens to come across the same usage scenario, here are some scripts I've been using to proxy domains inside Docker: https://github.com/w1ndy/docker-proxy-domain. Hope it helps!

skies457
  • 21
  • 1
  • 5