nginx 怎么自动跳转到 https 而不允许 http 访问
展开全部
这是我的nginx虚拟主机设置,给你点启发希望能帮到你。
server {
listen 80;
server_name alpha.com *.alpha.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
server_name alpha.com *.alpha.com;
ssl on;
ssl_certificate /wwwroot/ssl/server.crt;
ssl_certificate_key /wwwroot/ssl/server.key;
ssl_session_timeout 30m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
ssl_prefer_server_ciphers on;
root /wwwroot/alpha.com;
error_log /wwwroot/logs/error.log;
access_log off;
location / {
index index.html index.htm index.php;
}
}
server {
listen 80;
server_name alpha.com *.alpha.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
server_name alpha.com *.alpha.com;
ssl on;
ssl_certificate /wwwroot/ssl/server.crt;
ssl_certificate_key /wwwroot/ssl/server.key;
ssl_session_timeout 30m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
ssl_prefer_server_ciphers on;
root /wwwroot/alpha.com;
error_log /wwwroot/logs/error.log;
access_log off;
location / {
index index.html index.htm index.php;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询