Nginx更新后 - 网站坏了

时间:2017-04-17 13:07:22

标签: nginx debian

该网站多年来没有任何问题。我逐步执行更新,但这次它完全搞砸了。现在我得到了默认"欢迎来到Nginx"页。我仔细检查了我的所有文件夹位置等,但无法解决这个问题。不确定导致这个突破的原因。我将所有内容都追溯到其确切的文件夹位置。有趣的是,我无法找到对Nginx页面的默认欢迎的index.html。我现在在Nginx 1.12.0和Debian 8.7

这是conf

server {
    listen 80;
    server_name NAME.com www.NAME.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    #server_name NAME.com www.NAME.com;
    root /usr/share/nginx/html;
    index index.html index.htm;

    ssl_certificate /etc/letsencrypt/live/NAME.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/NAME.com/privkey.pem;

    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS;
    ssl_prefer_server_ciphers On;
    ssl_session_cache shared:SSL:128m;
    add_header Strict-Transport-Security "max-age=31557600; includeSubDomains";
    ssl_stapling on;
    ssl_stapling_verify on;  

    index index.html index.htm;    

    location / {
    try_files $uri $uri/ =404;
    }

    location ^~ /.well-known/ {
    allow all;
    }

    location ~* \.(ico|css|js|svg|gif|jpeg|jpg|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
    access_log off;
    log_not_found off;
    }

   gzip  on;
   gzip_comp_level  1;
   gzip_min_length  1000;
   gzip_proxied     expired no-cache no-store private auth;
   gzip_types       text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
   gzip_disable "MSIE [1-6]\.";
   gzip_vary on;
   gzip_buffers 16 8k;

   server_tokens off;
   add_header X-Frame-Options SAMEORIGIN;
   add_header X-XSS-Protection "1; mode=block";
} 

最后这里是nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  65536;
    use epoll;
    multi_accept on;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;

   #sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    on;

    client_body_timeout 3m;
    client_header_timeout 3m;
    keepalive_timeout 40;
    send_timeout 3m;

    include /etc/nginx/conf.d/default.conf;
}

2 个答案:

答案 0 :(得分:1)

疯狂 - 所以当NGINX更新时,它会将index.html文件替换为默认的“welcome to Nginx”html文件。我有一个备份,所以我很幸运,但是什么废话。他们为什么要替换index.html文件!!我看到文件大小,只是打开代码检查 - 否则我将永远不会发现。

答案 1 :(得分:0)

您的服务器块中没有端口443的server_name。您确定这是服务于您请求的服务器块吗?
检查/etc/nginx/sites-enabled中的默认文件。它的default_server - 指令中会有关键字listen