Join the community today
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 Premium Member Premium Member

    3,353
    318
    83
    May 31, 2014
    Ratings:
    +593
    Local Time:
    3:07 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

    40,634
    9,023
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,891
    Local Time:
    10:07 AM
    Nginx 1.15.x
    MariaDB 5.5/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

    4,549
    1,090
    113
    May 25, 2014
    Ratings:
    +1,591
    Local Time:
    8:07 AM
    Mainline
    10.2
    Yes it's not required unless you have ssl/443 port also.