求帮忙 关于HSTS没用
我用军哥的hsts强制从http跳转到https无法自动跳转,nginx域名配置文件如下,求帮忙看看谢谢各位大神server
{
listen 80;
#listen [::]:80;
server_name 777m777.com www.777m777.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/777m777.com;
include 22.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
server
{
listen 443 ssl;
server_name 777m777.com www.777m777.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/777m777.com;
ssl_certificate /etc/letsencrypt/live/777m777.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/777m777.com/privkey.pem;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
include 22.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
} HSTS必须是再访问过该https网站后才会生效的,首次访问是不生效的
http的网站server配置里可以加上301或只要访问了任意一个网站里的https连接以后就会强制https
回复 2# 的帖子
军哥 在cloudflare里启用HSTS不是比你的301更方便?:lol 直接全部强制到https cloudflare后台点一下就启用了
页:
[1]