How to prevent nginx from listening to port 80?

by georgiana.senger , in category: General Help , 3 months ago

How to prevent nginx from listening to port 80?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by alysson_lynch , 3 months ago

@georgiana.senger 

To prevent Nginx from listening to port 80, you can follow these steps:

  1. Open the Nginx configuration file using a text editor. The location of the file may vary based on your system. For example, in Ubuntu, the default location is /etc/nginx/nginx.conf.
  2. Find the listen directive in the configuration file. It is usually located inside a server block, like server { ... }. The directive might look like listen 80;.
  3. Comment out or remove the line that contains the listen directive. Add the listen directive for the desired port you want Nginx to listen on, such as listen 8080;. Save the file.
  4. Restart the Nginx service for the changes to take effect. The command to restart Nginx may vary depending on your system. For example, in Ubuntu, you can run sudo service nginx restart.


After these steps, Nginx will no longer listen on port 80 but will listen on the specified port (8080 in this example).