Changing the default http port to another one.

  • Thread starter heartless
  • Start date
In summary: The "Port" directive in httpd.conf allows you to specify a different port for the server to listen on. You would use this directive like this:Listen 668You can also try restarting Apache to see if that resolves the issue.
  • #1
heartless
220
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
  • #2
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.
 
  • #3
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:
  • #4
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
 
  • #5
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.
 
  • #6
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,
 
  • #7
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:
 
  • #8
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:

1. Why would someone want to change the default http port?

There are several reasons why someone might want to change the default http port. One common reason is to improve security by making it more difficult for hackers to find and access the server. Another reason could be to avoid conflicts with other applications that may be using the default port.

2. How do you change the default http port?

To change the default http port, you will need to modify the configuration file for your web server. The specific steps may vary depending on the server you are using, but generally you will need to find the "Listen" directive in the configuration file and change the port number to the desired one. Don't forget to save the changes and restart the server for them to take effect.

3. What is the recommended alternative port for http?

The recommended alternative port for http is 8080. This port is commonly used for proxy servers and is less likely to be blocked by firewalls. However, you can choose any available port number above 1024 for your http server.

4. Will changing the default http port affect my website's SEO?

No, changing the default http port will not have any impact on your website's SEO. Search engines do not consider the server port when ranking websites. However, it is important to ensure that your website is accessible through the new port and that there are no broken links or redirects.

5. Can changing the default http port cause any issues with my website?

In most cases, changing the default http port should not cause any issues with your website. However, if your website relies on specific port configuration for certain features or functionality, then it is possible that changing the port could cause those features to stop working. It is important to thoroughly test your website after making any changes to the server configuration.

Similar threads

Replies
3
Views
2K
  • Computing and Technology
2
Replies
35
Views
5K
  • Computing and Technology
Replies
15
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
525
  • Computing and Technology
Replies
2
Views
4K
  • Computing and Technology
Replies
4
Views
3K
  • Programming and Computer Science
Replies
19
Views
2K
  • Computing and Technology
Replies
4
Views
3K
  • Programming and Computer Science
Replies
12
Views
3K
Replies
1
Views
728
Back
Top