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 moving over everything that uses port 80 to port 9000 on my server, so I configured my apache + it's virtual hosts to listen to 9000 using ip xx.xx.xx.106, and I set up my iptables to preroute and they work fine.

The problem is I have a nodejs application running on xx.xx.xx.108:9000 that is not getting redirected when I go type in the address in my browser without the port #. Instead it goes to my servers default directory on port 80. (works fine when I go directly to the address:port)

Here's my routing

➜  public_html  iptables -t nat -L -v -n --line-numbers
Chain PREROUTING (policy ACCEPT 639 packets, 80831 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1      285 16568 REDIRECT   tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80 redir ports 9000

Chain POSTROUTING (policy ACCEPT 48 packets, 3125 bytes)
num   pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 45 packets, 2981 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        3   144 REDIRECT   tcp  --  *      *       0.0.0.0/0            127.0.0.1           tcp dpt:80 redir ports 9000
2        0     0 REDIRECT   tcp  --  *      *       0.0.0.0/0            173.234.60.106      tcp dpt:80 redir ports 9000
3        0     0 REDIRECT   tcp  --  *      *       0.0.0.0/0            173.234.60.108      tcp dpt:80 redir ports 9000

The strange thing is, is that there's nothing listening on port 80, and the index.php file in the default directory is compiling PHP correctly. Leading me to wonder if there's a default service that listens to port 80.

share|improve this question
    
Are you sure you do not see any cached content? To check if there's a service listening on port 80, you can use netstat -tlpn –  etagenklo Dec 1 '13 at 10:17
    
There's nothing on Port 80. how would i Check if the content is cached? –  Marius Miliunas Dec 1 '13 at 16:09
    
If there's no service on port 80 but you get a response when connecting via browser to port 80 without getting redirected, the content is probably cached by your browser. Try clearing your browser cache. –  etagenklo Dec 1 '13 at 21:15
    
Oh I thought it was caching on the servers end. It's not that. I tried changing the ports to redirect from port 3000 to 9001 and it still doesn't redirect. Is the OUTPUT necessary in this process at all, as I'm not really familiar what it's doing there, I've only seen other people add it? –  Marius Miliunas Dec 4 '13 at 19:03

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.