之前看到有文章说加入HSTS怎么怎么好,就试着申请了一下,在申请加入HSTS Preload List时,遇到了Warning: Unnecessary HSTS header over HTTP的错误,然后各种搜解决方法,找到后顺便记录下。
Nginx
修改配置文件为如下所示:
map $scheme $hsts_header {
https "max-age=31536000; includeSubDomains; preload";
}
server {
......(others)
add_header Strict-Transport-Security $hsts_header;
......(others)
}
修改后重启Nginx。
Apache
修改配置文件为如下所示:
<VirtualHost *:443>
......(others)
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
......(others)
</VirtualHost>
修改后重启Apache。
参考
How to add the HSTS header only for HTTPS requests on Nginx
Configure HTTP Strict Transport Security HSTS htaccess
6666665 ( VIP 1 )
广东这个设置不错,最近有人利用墙bug刷网站。不过你的网站在国内备案不用担心这个问题