Portal Home > Knowledgebase > Articles Database > How to have my server use a different port?


How to have my server use a different port?




Posted by TuxifieD, 10-07-2008, 09:44 PM
port 80 runs, but has no protection, I have the server protected on port 82, I want a way to beable to have a user when they go to my site automaticly be on port 82 but it not be shown at the end of the domain like it is now. anyway to do this?

Posted by pauln, 10-07-2008, 10:31 PM
You can edit your web server config to run on port 82. The user will have to specify ":82" at the end of the domain since it's a non-standard HTTP port.

Posted by RoseHosting, 10-07-2008, 11:11 PM
If your server is running on some linux distribition, you can do that by using iptables' PREROUTING rule. Install iptables if this application is not insalled on your server by default and run the 'mcedit /etc/sysconfig/iptables' or 'vi /etc/sysconfig/iptables' commands and insert the following lines at the beginig of the file: ============================================================================ *nat -A PREROUTING -d xxx.xxx.xxx.xxx -p tcp --dport 80 -j REDIRECT --to-port 82 COMMIT ============================================================================ Change the 'xxx.xxx.xxx.xxx' with your server's IP address, save changes to the file and restart iptables. That's it.

Posted by RoseHosting, 10-08-2008, 12:14 AM
If the above rule does not work, you could also try to add the following lines to the '/etc/sysconfig/iptables' file: =================================================================================== *nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination xxx.xxx.xxx.xxx:82 -A POSTROUTING -s xxx.xxx.xxx.xxx -p tcp --sport 80 -j MASQUERADE COMMIT =================================================================================== Change the 'xxx.xxx.xxx.xxx' with your server's IP address, save changes to the file and restart iptables. I hope this helps.

Posted by TuxifieD, 10-08-2008, 01:08 AM
im going to try this out and if it works ill let you know! thanks alot



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read