Changing the default http port to another one.

  • Thread starter Thread starter heartless
  • Start date Start date
AI Thread Summary
To change the default HTTP port on a router and forward it to a server, first ensure that the router's remote management is disabled to prevent access through the domain. Most routers allow HTTP administration on port 80 from the LAN side, while WAN access typically requires a custom port. Forwarding port 80 to the server allows access via the WAN IP, while the router's administration can still be accessed through its LAN IP. If the server needs to listen on a different port, modify the Apache configuration file (httpd.conf) using the "Listen" directive to specify the new port, ensuring it is above 1024 to avoid conflicts with reserved ports. After changing the port, remember to update the URL to include the new port number. If issues arise, it may be due to another service using the desired port or an incorrect configuration.
heartless
Messages
220
Reaction score
2
Hello,
I set up a server a while ago (I'm not very experienced in that kind of stuff). I have a router, and I forwarded ssh, smtp, and pop connections to the server, however my router provides an access to the settings through http, (http://192.168.1.1) and I'd like to change default http port (80) to 9999 or any others except for 80 so that the http is forwarded to my server. Right now, whenever I try to access my server, by domain, I get to the router which I don't want to be there. Any ideas how I can do that?

Thanks,
 
Last edited by a moderator:
Computer science news on Phys.org
Some routers (e.g. Netgear) allow you to change the port number for remote management, as well as restrict access to a certain set of IP addresses.

You could also do this...
turn off remote management. Then use (say) vnc or remote desktop (possibly via ssh) to access your computer and do the management locally. However, this may not work as well since your connection may drop if you need to reboot the router.
 
There's a couple of things to keep in mind. I'm assuming you have a configuration similar to the following:
Router:
. WAN IP 68.188.205.170 (given by yur ISP)
. LAN IP 192.168.1.1

Server:
. LAN IP 192.168.1.2

Most routers have HTTP based administration on port 80, as you mentioned, but usually only from the LAN side (WAN side administration has to be specificaly enabled, and it is usually over a custom port, like 8080). If you set your router to forward port 80 to your server then:
. 68.188.205.170:80 should take you to your server
. 192.168.1.1:80 should take you to the router's HTTP based administration
(Notice that port forwarding forwards requests on the specified ports from the WAN side only)
It's OK to have the router's HTTP based administration on port 80 from the LAN side, this should not cause any problems with your website. Also, forwarding port 80 won't make the router's HTTP based administration unavailable. So forward port 80 to your server, once you have that, then:
. http://68.188.205.170 will take you to your website
. http://192.168.1.2 will take you to your website
. http://localhost will take you to your website
. http://192.168.1.1 will take you to your router's HTTP based administration
. http://68.188.205.170:8080 will take you to your router's HTTP based administration (if you enable remote administration through port 8080).

You can also easily have your web server listening on some port other than 80, like 6969 and have your router forward WAN requests on port 80 to your server on port 6969.
 
Last edited by a moderator:
I tried this method above, but it ain't working. Although my router is set up not to allow remote administration, I still can access to it through my domain, from far, far away. Maybe the best thing would be to make apache listen onto another port, since my website is just for me and practice, and leave router at 80. It'd rather be more convenient for me to make my server listening to for example 666. But then again, how can I make apache listen to another port?
Thanks Job
 
To configure Apache to listen on a given port you have to edit the configuration file, i think it's httpd.config. You need to use the appropriate directive, here's some help:
http://httpd.apache.org/docs/2.2/bind.html

What kind of router do you have? Sounds like a strange router.
 
hmm it's quite weird. I wrote into httpd.conf Listen 668, but when I try to restart apache, I get:
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:668
no listening sockets available, shutting down

any ideas Job?

Thanks again,
 
Sounds like something else is using the port, or you didn't specify a valid interface address. I'm actually more of an IIS kind of guy. :smile:
 
heartless said:
hmm it's quite weird. I wrote into httpd.conf Listen 668,

No, what you want is the "Port" directive. (Gee, what an obscure name! :eek: ) Your httpd.conf almost certainly contains "Port 80" already. Just change the 80 to whatever new port you want and restart the server. Don't forget to tack the port number onto the host name or IP in the URL.

According to the Apache docs, you use the "Listen" directive when you want the server to listen to more than one port simultaneously, for example when you're running different virtual hosts on different ports.

Also, it's not a good idea to use a port below 1024, because those are often reserved by the operating system for other uses. Try something like 8080 or 8100 or 8000.
 
Last edited:
Back
Top