nginx增加了新的server name配置,发现nginx -s reload之后总是不生效。

http和https均可以打开页面,但是页面是别的server页面,使用的证书也是别的server的证书。

新加的配置文件如下

  1. server {
  2. listen 80;
  3. server_name img31.test.com;
  4. access_log /home/test/logs/accesslog/img31.test.com/img31.test.com_access.log main;
  5. location / {
  6. proxy_set_header Cookie $http_cookie;
  7. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  8. proxy_set_header X-Test-CDN-Proxy-Origin-Host cdn.m.test.cn;
  9. proxy_set_header X-Real-IP $remote_addr;
  10. proxy_set_header Host $host;
  11. index index.html index.htm;
  12. proxy_pass http://img31.test.com;
  13. }
  14. error_page 404 500 502 503 504 = http://www.test.com/404.html;
  15. }
  16. server {
  17. listen 443;
  18. server_name img31.test.com;
  19. access_log /home/test/logs/accesslog/img31.test.com/img31.test.com_access.log main;
  20. ssl on;
  21. ssi_types text/shtml;
  22. ssl_certificate crt/test-server.crt;
  23. ssl_certificate_key crt/test-server.key;
  24. ssl_session_timeout 5m;
  25. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  26. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  27. ssl_prefer_server_ciphers on;
  28. location / {
  29. proxy_set_header Cookie $http_cookie;
  30. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  31. proxy_set_header X-Test-CDN-Proxy-Origin-Host cdn.m.test.cn;
  32. proxy_set_header X-Real-IP $remote_addr;
  33. proxy_set_header Host $host;
  34. index index.html index.htm;
  35. proxy_set_header X-Forwarded-Proto $scheme;
  36. proxy_pass http://img31.test.com;
  37. }
  38. error_page 404 500 502 503 504 = http://www.test.com/404.html;
  39. }

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