我现在默认是
server
{
listen 80;
listen 443 ssl http2;
server_name www.11111.com 11111.com;
index index.html index.php index.htm;
root /www/wwwroot/www.11111.com;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /www/server/panel/vhost/cert/www.11111.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/www.11111.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-53.conf;
#PHP-INFO-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
access_log /www/wwwlogs/www.11111.com.log;
error_log /www/wwwlogs/www.11111.com.error.log;
}
这是默认的配置官方的强制SSL是
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
点了就是重定向过多 失败,我也没弄301重定向,之前弄了个非www跳转到www,现在也删除了也不顶用
按网上教程,下面这三种都不行
if ($scheme = http ) {
return 301 https://$host$request_uri;
}
if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}
if ($ssl_protocol = "") { rewrite ^ https://$server_name$request_uri? permanent; }
已经晕了
|
|