Learn about Centmin Mod LEMP Stack today
Become a Member

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

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +837
    Local Time:
    7:20 AM
    Nginx-1.26.x
    MariaDB 10.6.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

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    2:20 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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,449
    1,410
    113
    May 25, 2014
    Ratings:
    +2,204
    Local Time:
    12:20 PM
    Mainline
    10.2
    Yes it's not required unless you have ssl/443 port also.