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 reroute ports on a specific IP. Is there any way around this without using iptables?

BACKGROUND

I am using node.js & socket.io as a real time server. To ensure this server is available from all networks (which have strict security controls over port traffic), it has dedicated IP. This means it can use port 80 which is allowed in the majority of networks.

This has caused a second problem. Some anti virus software blocks this traffic on port 80. I have found that the best port to use is 4000.

I want to have two connection options for the client. Port 80 will be the default and if this fails it will use 4000. I then need to able to reroute port 4000 back to port 80 for both ports to use the same node.js server.

I have tried to use iptable to reroute this port but my VPS provider does not support NAT modules for iptables. They also cannot change the kernel to support this.

What are the other options available?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

I'd be looking for a new VPS provider... sounds like you're on a Virtuozzo system, which is never a pleasant experience.

I'd say your only option is going to be to have some sort of proxy listening on whatever port you want, and forward the requests through to the right place. I'd be inclined to use haproxy, simply because it's at about the right level of simplicity and robustness. If you don't need client IP address data, you could just run it in TCP connection mode, otherwise run it as a HTTP proxy and have it insert the appropriate headers to record the client IP. You could run a fully-fledged HTTP server and run it as a reverse proxy, but it's massive overkill and is only likely to cause complications, especially given the less-than-mainstream uses to which you'll be putting it.

share|improve this answer
    
Thank you. I am with Godaddy.. I would like to change. Can you recommend a good provider? I will check out haproxy. Seems like the best option. –  KitCarrau Aug 22 '11 at 11:35
2  
Installing Linux on a dead rodent would be an improvement over Godaddy, based on what I've heard (Ubuntu's "Stinky Squirrel" release is planned to have support for most common rodents, I believe). We don't really do "shopping" questions here; for rationale and a list of better places to discuss such things, see this question. –  womble Aug 22 '11 at 11:44
    
Thanks Womble. Haproxy is working perfectly..! Is there any advantage to using IPtables for port rerouting over haproxy or similar software? –  KitCarrau Aug 23 '11 at 9:32
    
Yes, iptables preserves all the TCP connection information from the client, which is much nicer than trying to emulate it with HTTP headers. –  womble Aug 23 '11 at 9:53

You could use the redirect feature from xinetd or netcat or even a combination of them. as alternative you could (i wouldn't recommend it though) also use ssh portforwarding features.

Check the manpages for the above mentioned ...

HTH

share|improve this answer

You can try nginx; it'd be a way more effective than [x]inetd and co.

share|improve this answer
    
I'm sure you're right that it would work, but in what way would it be "way more effective" than using, say, xinetd and redirect? –  MadHatter Aug 22 '11 at 15:03
    
Nginx is light-weight, heavy load optimized software masterpiece. [x]inetd was never optimized for heavy-traffic pattern. You may read this up: nginx.org/en/#architecture_and_scalability –  poige Aug 22 '11 at 15:17
    
Fair enough, though xinetd is very lightweight, too, and I've never known it choke under load. Given that the OP doesn't mention heavy loads as his/her usage case, I'm not sure I would steer him/her straight towards a custom package to do something that existing system utilities should do just fine. –  MadHatter Aug 22 '11 at 15:20
    
I think Nginx would be such an experience to the OP, that would only help (considering his area of interest), and it would be a way more helpful than playing with [x]inetd instead. –  poige Aug 22 '11 at 15:29
1  
Fair enough! I disagree with you quite strongly, but yours is a worthwhile and informed opinion; at least the OP now has some idea why (s)he might want to consider nginx over xinetd (or, indeed, why (s)he might want to run screaming away from it!). –  MadHatter Aug 22 '11 at 15:33

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.