在安全风险总结中,要求为 Cookie 设置 Httponly 和 secure 属性。
使用 add_header
An easy way to set cookie flag as HTTPOnly and Secure in Set-Cookie HTTP response header. Take a backup of the necessary configuration file and add the following in nginx.conf under http block.
在 HTTP 返回头中修改 HTTPOnly
和 Secure
是一个比较简单的方法。请备份 nginx 的配置文件,然后在 http 下添加以下内容。
add_header Set-Cookie "Path=/; HttpOnly; Secure";
重启 Nginx 检查结果。
使用 proxy_cookie_path
另一种选择是在ssl.conf或default.conf中添加下面的语法:
proxy_cookie_path / "/; HTTPOnly; Secure";
重启 Nginx 检查结果。
这篇文章还没有人留言,快来抢沙发吧。