Nginx:避免nginx:[警告] 0.0.0.0:80上的服务器名称“索引”冲突,已忽略

时间:2018-08-12 20:02:33

标签: nginx

我有多个指向同一台服务器的网站(只是一个静态网站)。在此服务器中,我正在使用Nginx。我有多个配置文件,每个网站的每个配置文件。例如,这是我的示例:

Double deg = 45.0d;
float floatDeg = deg.floatValue();

当我运行以下命令时:data['last_pitch'] = False g = data.groupby(['gameString', 'pitcherId']) for x, pitcher in g: pitcher.iloc[-1]['last_pitch'] = True 用于检查nginx语法。我遇到以下警告:

server {
   root /var/www/example/build;
   server_name example.com www.example.com
   index index.html index.htm;
   location / {
      try_files $uri $uri/ /index.html;
   }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


   listen 80 default_server;
   server_name example.com www.example.com
   index index.html index.htm;
    return 404; # managed by Certbot
}

我已经测试过,发现这些警告不是问题。 (因为我在多个文件上监听相同的端口)。但是我不知道是否在其中一个文件中删除了侦听端口,是否有任何问题?还有其他禁用此警告的方法。

谢谢

1 个答案:

答案 0 :(得分:2)

您只是忘记在;的末尾添加一个server_name

server_name example.com www.example.com
index index.html index.htm;

Nginx将继续使用indexindex.htmlindex.html作为备用服务器名称读取下一行。