Nginx – Connect to upstream/backend via socks5 proxy in NginX/HAProxy

haproxynginxPROXY

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).

Best Answer

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!