欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 锐评 > openresty(Nginx) 301重定向域名 http访问强制使用https

openresty(Nginx) 301重定向域名 http访问强制使用https

2025/2/23 7:48:48 来源:https://blog.csdn.net/tonyhi6/article/details/139746253  浏览:    关键词:openresty(Nginx) 301重定向域名 http访问强制使用https

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;

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词