Nginx is an open source stable server that powers some of the most high traffic websites in internet today. Among web services, Nginx web server can be successfully deployed as an load-balancer, web reverse proxy or as a POP and IMAP proxy server.
By default, Nginx HTTP server listens for incoming connection and binds on port 80, which represents the standard web port. However, the TLS configuration, which is not enabled by default in Nginx, listens for secure connections on port 443.
In order to make Nginx HTTP server to listen for incoming web connections on other non-standard ports, we need to edit the main configuration file and change or add a new statement to reflect this fact.
In Ubuntu and Debian based system, we need to modify the /etc/nginx/sites-enabled/default file and on RHEL and CentOS based distributions edit /etc/nginx/nginx.conf file.
To begin with, open Nginx configuration file with a text editor, and change the port number as shown in the below excerpt.
In this excerpt we’ll configure Nginx HTTP server to listen for incoming connections on port 3200. Search for the line that begins with
listen
statement in server directive and change the port from 80to 3200, as illustrated in the below image.After altering Nginx port statement, you need to restart the web server in order to bind on the new port on Debian based Linux distributions. Verify local network sockets table with netstat or ss command. Port 3200 should be displayed in your server local network table.
In CentOS or RHEL based Linux distribution you need to install policycoreutils package and add the below rules required by SELinux for Nginx to bind on the new port.
Finally restart Nginx HTTP server to apply changes.
Check network tables listening sockets.
To check if the web server can be accessed form computers in your network, open a browser and navigate to your server IP address or domain name on port 3200. You should see Nginx default web page, as illustrated in the below screenshot.
However, if you can’t browse Nginx web page, return to server console and check the firewall rules to allow incoming traffic on port 3200/tcp.
No comments:
Post a Comment