模式:
Nginx
修改网站配置文件:
在
1 | listen 80; |
下面添加
1 2 3 4 | listen 443 ssl;
server_name www.xmspace.net;
ssl_certificate /www/ssl/pem.pem;
ssl_certificate_key /www/ssl/key.key; |
重启nginx服务
https配置成功
301跳转
1 2 3 4 5 6 7 8 9 10 11 | #下面两个一样的效果
if ($scheme = http ) {
return 301 https://$host$request_uri;
}
if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}
#http://nginx.org/en/docs/http/ngx_http_ssl_module.html#errors
error_page 497 https://$host$request_uri; |
