Forwarding Nginx traffic through Socks5 proxy

95 views Asked by At

I have configured Nginx as a reverse proxy which have multiple rules based on request path, now I want to send Nginx traffic through a Socks5 proxy. At first, I configured the proxy as system proxy using this command:

export all_proxy=socks5://127.0.0.1:2080

But it seems to Nginx not using all_proxy environment variable, so I tried to forward the Nginx traffic using these commands:

iptables -t nat -A OUTPUT -m owner --uid-owner www-data -p tcp -j DNAT --to-destination 127.0.0.1:2080

iptables -t nat -A OUTPUT -m owner --uid-owner www-data -p udp -j DNAT --to-destination 127.0.0.1:2080

After axecuting these command, configured reverse proxy in Nginx no longer worked ! So, how can I forward Nginx traffic through Socks5 proxy?

0

There are 0 answers