我真的不知道出了什么问题,但 https 安全标头与 http 配合得很好,但与我网站上的 https 配合不好。我已经通过 htaccess 设置了:
<IfModule mod_headers.c>
Header always append X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header always append X-Content-Type-Options nosniff
</IfModule>
当我测试我的网站时,这就是结果:
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Date: Thu, 30 Dec 2021 12:33:49 GMT
Server: Apache
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Location: https://www.www.mywebsite.com/
Ip: 162.252.xx.xx
Cache-Control: max-age=2592000
Expires: Sat, 29 Jan 2022 12:33:49 GMT
Content-Length: 242
Connection: close
Content-Type: text/html; charset=iso-8859-1
> --------------------------------------------
> 200 OK
> --------------------------------------------
Status: 200 OK
Code: 200
Date: Thu, 30 Dec 2021 12:33:49 GMT
Server: Apache
Connection: close
Content-Type: text/html
因此您可以看到安全标头 X-XSS-Protection、X-Frame-Options 和 X-Content-Type-Options 是通过通过 http://www.mywebsite.com 但使用 https 访问 url 来设置和发送的://www.mywebsite.com 不是。
为什么它通过http协议而不是通过https协议工作?问题出在哪里?该怎么办?
尝试使用这些线....
Header always set X-Frame-Options SAMEORIGIN
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff
您会建议我什么来保护我的以下网站免受黑客攻击。 https://yoofinder.com/