3

I'm a stack exchange Virgin.

Is it possible to forward data to the parent proxy based on the listen-address port in was recieved

For example my firefox browser is set to use proxy 90.91.92.93:8118

And proxy 90.91.92.93 then forwars to proxy 90.91.92.101:8118

If my Firefox browser was set to use a different proxy port 90.91.92.93:8119, then forwards to a different proxy 90.91.92.102:8118

So proxy 90.91.92.93 forwards request in the following way.

Firefox--->90.91.92.93:8118---> 90.91.92.101:8118
Firefox--->90.91.92.93:8119---> 90.91.92.102:8118
Firefox--->90.91.92.93:8120---> 90.91.92.103:8118
And so on

This is just for forwarding http requests over 2 proxies, but having some logic in the process

larsks
  • 32,449
  • 5
  • 54
  • 70
  • What distribution is your server using? What firewall and/or proxy is installed? What rules have you tried that didn't work? – Julie Pelletier May 27 '16 at 22:10
  • You can certainly configure multiple forward proxies listening on different ports. What you have described would be fairly easy to implement using just about any proxy software. – larsks May 27 '16 at 22:11
  • I'm running Ubuntu 14, using whatever comes as standard as a firewall and using privoxy as the proxy, on all nodes. – Linuxvirgin May 28 '16 at 06:17
  • if you don't need local caching of the http responses then you could set up port forwarding rules in your firewall configuration. – Serge May 28 '16 at 08:45
  • Apologies for my little knowledge of Linux but When you say firewall, are you talking about iptables, or another specific firewall product. – Linuxvirgin May 28 '16 at 09:07
  • If your talking about iptables can you provide a sample piece of code that would do the job – Linuxvirgin May 28 '16 at 09:08
  • Yes, I meant `iptables`. I am not familiar with Ubuntu (how firewall is managed there), so raw `iptables` rule would be: `iptables -t nat -A PREROUTING -p tcp -d 90.91.92.93 --dport 8118 -j DNAT --to-destination 90.91.92.101:8118`. Also I would add `-i` option to bound that rule to your local net interface or `-s` option to match local addresses, so no 'foreign' traffic would be forwarded to the proxy – Serge May 28 '16 at 09:20
  • serge..... Your a legend... Thank you so much. I will try this Asap and let you know.... – Linuxvirgin May 28 '16 at 09:39
  • I did a little more research and adapted your snippet to my needs and entered it into the shell. I was a little confused when it didn't show when I typed iptables -L, but eventually figured out that I needed to add the -t nat to the iptables cmd. – Linuxvirgin May 29 '16 at 09:45
  • But it doesn't seem to forward the request to the next proxy in the line. – Linuxvirgin May 29 '16 at 09:46
  • The traffic originates from the Firefox browser with the proxy set to 90.91.92.93:8118 (a privoxy proxy). Is it because privoxy is handling the request for instead of iptables. Would I not have to configure privoxy to pass the request to the next proxy in the chain (depending on what port it was received on. – Linuxvirgin May 29 '16 at 09:49
  • Been researching some more and realised I maybe should of mention traffic coming in is on eth0 interface and traffic going out is on eth1. – Linuxvirgin May 29 '16 at 22:29

0 Answers0