HTTP/HTTPS 配置

  1. server {
  2. listen 80;
  3. server_name <域名> localhost;
  4. return 301 https://$server_name$request_uri;
  5. location ~*^.+$ {
  6. root <网站的本地路径>;
  7. index index.html;
  8. }
  9. }
  10. server {
  11. listen 443;
  12. server_name <域名>;
  13. ssl on;
  14. ssl_certificate cert/<数字_域名>.pem;
  15. ssl_certificate_key cert/<数字_域名>.key;
  16. ssl_session_timeout 5m;
  17. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  18. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  19. ssl_prefer_server_ciphers on;
  20. location ~*^.+$ {
  21. root <网站的本地路径>;
  22. index index.html;
  23. }
  24. }