samedi 27 décembre 2014

Redirect outcomming traffic to local server


I have a Apache web server set which listens on port 4000 and I want to use this (local) server as a kind of proxy.


The idea is to redirect all the local outcomming HTTP traffic (port 80) to my server at 127.0.0.1:4000. Of course, the server must be able to send request on port 80.


I tried to update iptables like this :



iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:4000


Obviously it does not work because the traffic from my server is also redirected to itself.


The question is: how can I only authorize HTTP request from my server?


Example:



  1. A request is sent to www.google.com

  2. The request is redirected to my server (127.0.0.1:4000)

  3. The server receives the request, do some stuff, then sends a request to www.google.com


I managed to do the first part (2.) but because of that my server cannot access www.google.com as it is also redirected to itself.



Aucun commentaire:

Enregistrer un commentaire