Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a linux server and have a proxy server on another machine.

My linux server needs connect to port 'x' on ip 'y'

Is it possible to create iptables rule or another way to: when my linux server tries to connect to port 'x' on ip 'y' uses my proxy server on another machine?

In other words, I need to my server's ip changes when it needs to connect port 'x' on ip 'y' by using another proxy server machine.

simple question: "need a way to proxify a port"

share|improve this question

closed as not constructive by Bart De Vos, womble, Khaled, Tom O'Connor, Skyhawk Apr 22 '12 at 14:30

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Just cutting and pasting your question back in when it's rejected doesn't accomplish anything but annoying people. Figure out why it was rejected and fix it. – geekosaur Apr 22 '12 at 9:46
@geekosaur i have sent it to… it says: "This question might be better asked on" – Metalik Apr 22 '12 at 10:03
simple question: "need a way to proxify a port" – Metalik Apr 22 '12 at 15:26

You can redirect traffic to a port on the local machine like this:

sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination

You can't redirect traffic to an arbitrary machine though, see the comment at the bottom of (which still seems to be valid - I tested it)

Given this restriction, you might be able to place a reverse proxy on the local machine to forward your HTTP requests to the proxy. Nginx should be able to do this, see

Whether this works or not will probably depend on how your proxy is configured...

share|improve this answer
1. is it possible to change to an external ip:port ? – Metalik Apr 22 '12 at 14:30
2. 8000 is port of proxy server? – Metalik Apr 22 '12 at 14:31
3. if your solution work, i can config proxy server to use cascade proxy – Metalik Apr 22 '12 at 14:32
It's not possible to change to an external port, the packets will not be rewritten correctly. Yes, 8000 is the port of the proxy server – dwurf Apr 22 '12 at 22:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.