Question

Nginx ports (8080)

Hi, I’m configuring nginx and everything seems to work OK, except that it only “listens” to the default port (80). I’m struggling to configure it to listen to port 8080. I’ve tried with “listen 8080;” “listen 127.0.0.1:8080;” “listen localhost:8080;”… but all are ignored.

I made those changes in the sites-enabled file (/etc/nginx/sites-available/mysite). Do I have to change something in nginx.conf or in other file?

Thanks in advance for your help!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Kamal, I checked and there are some errors, but apparently all related to my CMS (Drupal), not to nginx. <br> <br>Gavin, I haven’t installed any firewall (at least not consciously). <br> <br>Dave, I don’t fully understand what you say (I’m very new to nginx and to sysadmin issues in general) but I think that could be the problem or at least related to that: <br>I have several domains in the same nginx server and therefore several “server declarations” in the same configuration file (all included in /etc/nginx/sites-available/mysite). When I put listen 8080; in the first server declaration (save and restart nginx) and go to that first domain, it redirects to the next domain in the nginx configuration file. <br> <br>Simplifying, it’s something like this: <br> <br>server { <br> listen 8080; <br> server_name www.domain1.com; <br> … <br>} <br>server { <br> listen 80; <br> server_name www.domain2.com; <br> … <br>} <br> <br>With this configuration, when I open www.domain1.com in my browser it redirects me to www.domain2.com. That could be related to what you were talking about? That gives more clues about what could be my problem? <br> <br>Thanks again for all your quick responses!

Are you running a firewall? If you want to connect externally to it, you may have to add a rule in to iptables.

Folks, this is a banana slip ! the conf file is being generated dynamically and actually does not point to /etc/nginx/available-sites/default !!! Take a look at ps -ef | grep nginx and you will see the actual conf file !!!