Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to redirect traffic from one IP reached on a specific port to a website. For example I have two external ips, lets say 194.145.63.1 and 194.145.63.2 set on one network card as 194.145.63.1 - eth0 and 194.145.63.2 -eth0:1 mywebsite.com allows access only from 194.145.63.1 and I want to set my rules like if I hit http://194.145.63.2:8080 to open mywebsite.com trough 194.145.63.1.

Thanks in advance!

share|improve this question
add comment

1 Answer 1

Something like this?

iptables -t nat -A PREROUTING -p tcp -i eth0 --dst 194.145.63.2 --dport 8080 -j REDIRECT --to-ports 80

Though I'm not sure if that's what you really want.

I think what you actually want would be to set up a rewrite on the web server running on 194.145.63.2:8080 to 301 redirect to http://194.145.63.1, which is a question that will depend on what kind of software you're running on 194.145.63.2:8080.

Also, if you want traffic only on 194.145.63.1, why bother exposing 194.145.63.2:8080 at all?

Please clarify the problem, rather than asking for details on how to implement your (possibly suboptimal) solution.

share|improve this answer
    
Thanks for the answer cjc. Basically what I want is: mywebsite.com is accessible only from 194.145.63.1 and I want to be able to connect to specific port to that or other IP on the same 194.145.63.1 server and see the website. Kind of proxy but I want to avoid squid and just use IPtables –  Anthony Apr 7 '12 at 14:21
    
You don't need Squid. You can run a reverse proxy using most web server software, which will do what you want, and is the more "standard" solution. Google for "reverse proxy" with whatever software you're using, and then block access on that other IP. –  cjc Apr 7 '12 at 15:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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