VPS侦探论坛

 找回密码
 注册
查看: 4415|回复: 3

求帮忙 关于HSTS没用

[复制链接]
发表于 2016-1-14 21:15:29 | 显示全部楼层 |阅读模式

我用军哥的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_pass  unix:/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_pass  unix:/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;
    }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-1-15 10:18:44 | 显示全部楼层


HSTS必须是再访问过该https网站后才会生效的,首次访问是不生效的

http的网站server配置里可以加上301或只要访问了任意一个网站里的https连接以后就会强制https
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-1-15 15:31:59 | 显示全部楼层

回复 2# 的帖子


军哥   在cloudflare里启用HSTS不是比你的301更方便? 直接全部强制到https
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-1-15 15:42:29 | 显示全部楼层



cloudflare后台点一下就启用了
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-28 19:27 , Processed in 0.039726 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表