nginx修改配置后不生效的問題


nginx增加了新的server name配置,發現nginx -s reload之后總是不生效。

http和https均可以打開頁面,但是頁面是別的server頁面,使用的證書也是別的server的證書。

新加的配置文件如下

server {
    listen       80;
    server_name  img31.test.com;
    access_log  /home/test/logs/accesslog/img31.test.com/img31.test.com_access.log  main;
    location / {
        proxy_set_header Cookie  $http_cookie;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Test-CDN-Proxy-Origin-Host cdn.m.test.cn;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header Host       $host;
        index  index.html index.htm;
        proxy_pass    http://img31.test.com;
    }
    error_page 404 500 502 503 504 = http://www.test.com/404.html;
}





server {
    listen       443;
    server_name  img31.test.com;
    access_log  /home/test/logs/accesslog/img31.test.com/img31.test.com_access.log  main;
  ssl on;
    ssi_types text/shtml;
    ssl_certificate crt/test-server.crt;
    ssl_certificate_key crt/test-server.key;
    ssl_session_timeout  5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers   on;
    location / {
        proxy_set_header Cookie  $http_cookie;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Test-CDN-Proxy-Origin-Host cdn.m.test.cn;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header Host       $host;
        index  index.html index.htm;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_pass    http://img31.test.com;
    }
    error_page 404 500 502 503 504 = http://www.test.com/404.html;
}
View Code

 

 

 

最后想起來用nginx -t才發現配置中的log輸出目錄還沒有創建,mkdir后問題解決。

配置不生效時,打開了其他server的80端口和443端口

 

改得多了,有時就忽略了nginx -t這一步,會忽略掉一些常見的小問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM