最近項目處於測試階段,在安全報告中存在" X-Frame-Options 響應頭缺失 "問題,顯示可能會造成跨幀腳本編制攻擊,如下圖:
X-Frame-Options:
值有三個:
(1)DENY:表示該頁面不允許在 frame 中展示,即便是在相同域名的頁面中嵌套也不允許。
(2)SAMEORIGIN:表示該頁面可以在相同域名頁面的 frame 中展示。
(3)ALLOW-FROM https://example.com/:表示該頁面可以在指定來源的 frame 中展示。
配置Apache:
(如果是在本地的話,就是在httpd.conf里面配置;如果是linux(ubuntu的話)就是在apache2.conf里面),找個空的位置加入這行代碼,具體看你是選擇哪種
Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration
header的方法模塊沒有安裝,我們需要先自行安裝一下:
先輸入 a2enmod heade ,然后需要重啟一下Apache,輸入service apache2 restart
配置Nginx:
配置 nginx 發送 X-Frame-Options 響應頭,把下面這行添加到 'http', 'server' 或者 'location' 的配置中:
<span style="font-size:14px;">add_header X-Frame-Options SAMEORIGIN;</span>
配置IIS:
配置 IIS 發送 X-Frame-Options 響應頭,添加下面的配置到 Web.config 文件中:
<system.webServer> ... <httpProtocol> <customHeaders> <add name="X-Frame-Options" value="SAMEORIGIN" /> </customHeaders> </httpProtocol> ... </system.webServer>