8

I want nginx to stop listen to port 80. I only found people with bugs but no doc about doing it on purpose. I can't disable it, and I read too :

#listen   80; ## listen for ipv4; this line is default and implied

English is not my mother tongue, but I understand "implied" meant this doesn't need to be declared, so even though it's in commentary, the server still listen to 80. How can I disable this ? Thank you.

2
  • Where do you want nginx to listen ?
    – user9517
    Jun 4, 2013 at 8:28
  • I want it to listen to 8080 or 8180
    – Pygmay
    Jun 4, 2013 at 8:34

1 Answer 1

14

As you have commented out the listen directive nginx will fall back to it's default behaviour which is to listen on port 80 as it says in the comment after the ##.

To have nginx listen elsewhere you need to tell it to do that using a listen directive e.g.

listen 8080; 

or

listen 192.168.2.3:8080;
3
  • And it will stop listening to 80 just by declaring another port ?
    – Pygmay
    Jun 4, 2013 at 8:40
  • Yes, that's what he is saying.
    – Jenny D
    Jun 4, 2013 at 8:41
  • I think this will be used even for port 80 if its the 1st server. Because the 1st one if default
    – variable
    Feb 16, 2022 at 8:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .