Welcome to Centmin Mod Community
Register Now

Nginx Nginx vhost missing listen 80?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, Jul 5, 2014.

Tags:
  1. pamamolf

    pamamolf Well-Known Member

    4,022
    421
    83
    May 31, 2014
    Ratings:
    +816
    Local Time:
    11:22 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    Hi

    I just create a new vhost and i check the config and i got this:


    Code:
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    #server {
    #  listen  80;
    #  server_name mydomain.com;
    #  return 301 $scheme://www.mydomain.com$request_uri;
    #  }
    
    server {
      server_name mydomain.com www.mydomain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=32k;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      #try_files     $uri $uri/ /index.php;
    
      }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
    
    So as i do not use the redirect from non-www to www i keep the comments there.

    But on the test domain config i can see this:

    Code:
    server {
       listen  80;
      server_name mydomain.com www.mydomain.com;
    
    But the listen 80 is missing here on my main domain config above ......

    It seems that i am very unlucky after doing it more than 20 times to not be able now to get it working :(
     
  2. eva2000

    eva2000 Administrator Staff Member

    50,478
    11,663
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,088
    Local Time:
    6:22 PM
    Nginx 1.25.x
    MariaDB 10.x
    it defaults to listen 80 if listen 80 is omitted so shouldn't be a problem and works for me
     
  3. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    4:22 PM
    Mainline
    10.2
    Yes it's not required unless you have ssl/443 port also.