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.
vim /etc/nginx/sites-enabled/default [On Debian/Ubuntu]
vim /etc/nginx/nginx.conf [On CentOS/RHEL]
修改如下
- 修改nginx.conf文件
- 重启nginx
systemctl restart nginx
netstat -tlpn| grep nginx
ss -tlpn| grep nginx