nginx修改配置后不生效的问题

原文链接:http://www.cnblogs.com/csliwei/p/6248614.html

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这一步,会忽略掉一些常见的小问题。

转载于:https://www.cnblogs.com/csliwei/p/6248614.html

展开阅读全文
博主设置当前文章不允许评论。

没有更多推荐了,返回首页