测试环境概述
Debian 9 Nginx
注意 阿里云的机器不支持 https 非 443 端口的配置;
配置ssl 证书之前先准备好域名证书相关信息(手动申请证书) Or acme 结合阿里云解析或cloudflare DNS申请证书
- server {
- listen 8000 ssl http2;
- server_name www.domain.com;
- set $root_path '/home/webapps/website/www.domain.com';
- root $root_path;
- index index.html;
- access_log /var/log/nginx/www.domain.com-access.log;
- error_log /var/log/nginx/www.domain.com-error.log;
- ##### 跳转
- #if ($server_port !~ 8000){
- rewrite ^(/.*)$ https://$host$1 permanent;
- #}
- #ssl on;
- ssl_certificate /root/.acme.sh/www.domain.com/fullchain.cer;
- ssl_certificate_key /root/.acme.sh/www.domain.com/www.domain.com.key;
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
- add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
- ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
- ssl_prefer_server_ciphers on;
- #ssl_verify_client on;
- error_page 497 https://$host:$server_port$request_uri;
- location / {
- try_files $uri $uri/ @router;
- index index.html;
- }
- location @405{
- root /opt/htdocs;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- location @router {
- rewrite ^.*$ /index.html last;
- }
- }
没有评论