关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

云服务器nginx强制网站使用https

发布时间:2024/12/12 12:53:25
香港云服务器

配置文件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;

}