云服务器nginx强制网站使用https
技术问题
云服务器nginx强制网站使用https
2024-12-21 09:05
云服务器nginx强制网站使用https
配置文件test.test.com.conf具体的站点配置如下:
# HTTPS server
server {
listen 80;
listen 443 ssl;
server_name test.test.com;
ssl on;
ssl_certificate /usr/local/nginx/certs/1_test.test.com_bundle.crt;
ssl_certificate_key /usr/local/nginx/certs/2_test.test.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://www.8a.hk:3000;
}
#让http请求重定向到https请求
error_page 497 https://$host$request_uri;
}
標簽:
- 云服务器nginx强制网站使用https