1 访问http
2 修改配置访问
- server {
- listen 80;
-
- server_name example.cn;
- return 301 https://$server_name$request_uri;
-
-
- access_log /data/logs/czgzzfjgsup_access.log access;
- error_log /data/logs/czgzzfjg_error.log error;
-
- #
-
- location / {
-
- root /usr/local/openresty/nginx/html/;
- }
-
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
-
3 在访问http会强制跳转到https
- #全站统一强制使用https,启用严格传输安全,在一年内,任何使用HTTP的请求都将被浏览器自动转换为HTTPS请求
- vim nginx.conf
- add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always;