配置 SSL+ 端口拜访
在生产环境遇到这样一个问题,一个我的项目只给了一台服务器和一个域名,我的项目呢是有 3 个利用端,有两个前端利用用的是 VUE 开发,所以一个域名就显得不够用了,而且域名是配置了 SSL,前端利用是嵌入到企业微信利用中的,所以不放心用户记不住域名地址,就筹备用 SSL +port 的形式来解决这个问题。以一个非 443 端口和 443 端口为例进行配置:
443 端口配置
server
{
listen 80;
listen 443 ssl http2;
server_name www.domain.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/www.domain.com/;
#SSL-START SSL 相干配置,请勿删除或批改下一行带正文的 404 规定
#error_page 404/404.html;
#HTTP_TO_HTTPS_START
if ($server_port !~ 443){rewrite ^(/.*)$ https://$host$1 permanent;
}
#HTTP_TO_HTTPS_END
ssl_certificate /www/server/panel/vhost/cert/www.domain.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/www.domain.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
access_log /www/wwwlogs/www.domain.com.log;
error_log /www/wwwlogs/www.domain.com.error.log;
}
非 443 端口配置
server
{
listen 4000 ssl http2;
server_name work.firepa.vip;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/www.domain.com/other-port;
#SSL-START SSL 相干配置
ssl_certificate /www/server/panel/vhost/cert/www.domain.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/www.domain.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
access_log /www/wwwlogs/www.domain.com.other.port.log;
error_log /www/wwwlogs/www.domain.com.other.port.error.log;
}