GIT – How do I configure Apache to listen on multiple ports under RHEL / Fedora / Server?

Multiple ports can be configured via Listen directive under Apache web server. By default httpd listens on TCP port 80.

How to configure httpd to listen multiple ports?

Open configure file /etc/httpd/conf/httpd.conf and modify the Listen directive tells the server to accept incoming requests on the specified port. Multiple Listen directives may be used to specify a number of ports to listen to.
# vi /etc/httpd/conf/httpd.conf
Find line that read as follows:
Listen 80
Force httpd to listen to port 81:
Listen 81
Force httpd to listen on both port 80 and 81:
Listen 80
Listen 81

Save and close the file. Restart httpd:
# /etc/init.d/httpd restart

A note about

If you are using SELinux, make sure port 81 is configured and not blocked by SELinux. By default SELinux only allows port number 80 and 443 for httpd service. To display current port contexts, enter:
semanage port -l | grep http
semanage port -l | grep -w '^http_port_t'

Sample outputs:

http_port_t                    tcp      80, 443, 488, 8008, 8009, 8443

To add port 81 to port contexts, enter:
# semanage port -a -t http_port_t -p tcp 81
You can verify new settings, enter:
# semanage port -l | grep http_port_t
Sample outputs:

http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443

Finally, reload or restart the HTTPD server, enter:
# /sbin/service httpd reload

(13)Permission denied: make_sock: could not bind to address

In apache, this type of error occurs at the time of starting the service after editing the httpd.conf file to listen to a particular port number.. The reason is apache allowing only specified http port numbers, and the one you have given is not in that list, first check that by

semanage port -l|grep http

If the port number is not in the list (ex: 4080), add by using,

semanage port -a -t http_port_t -p tcp 4080

Now start apache, you are done

Print Friendly, PDF & Email



Bài viết liên quan