How to change Nginx port in Linux

How to change Nginx port in Linux

Step 1 : Check the default port by accessing the server IP address in the browser .



Step 2:  Login into the server using root credentials through putty .




Step 3: Open Nginx configuration file with a text editor .


Command : 


# vi /etc/nginx/nginx.conf



Press ‘ I ’ for the insert/modification mode .


Step 4: Change the default port of the nginx to the custom port .


Before change : port is 80 as shown below in screetoshot



After change : Port has been changed to 8081 (here) as shown in screenshot .



Step 5 : Restart the nginx and network service .


Command : 


# systemctl status nginx

# systemctl status network





Step 6 : Now check the webserver while accessing the server IP_address:8081  in the browser. 


URL: - http://server_domain_name_or_IP:8081 




    • Related Articles

    • NGINX: Installation and Basic Setup

      Before You Begin You need root access of the server or a sudo  privileged user account. Set the hostname of your cloud server. Update your server. Install NGINX Stable Versus Mainline The first decision on your installation is whether you want NGINX ...
    • How to Configure NGINX

      NGINX is a web server designed for high-traffic cases that is lightweight and highly efficient. The ability to easily support static content such as HTML and media files is one of the most significant features of NGINX. NGINX uses a predictable ...
    • Use NGINX as a Reverse Proxy

      What is a Reverse Proxy? A reverse proxy is a server between internal and external clients which transmits clients requests to a different server. Although other standard applications, such as Node.js, can support themselves, NGINX has a range of ...
    • NGINX : Enable TLS or HTTPS Connections

      The Secure Socket Layer (SSL) is the successor to Transportation Layer Security (TLS). It provides stronger and more powerful HTPS and includes non-SSL improvements such as Forward Confidentiality, modern OpenSSL cipher suites, and ...
    • Nginx Installation in CentOS 7

      Step 1: Add Nginx repository . Command :  # yum install epel-release Step 2:  Install Nginx using following command . Command: # yum install nginx Step 3: Start the service of Nginx . Command :  # systemctl start nginx Step 4: Check status of Ngnix . ...