Linux-NGINX 能否添加P3P头,如何添加。

Linux-NGINX 能否添加P3P头,如何添加。 - 德问:编程社交问答

NGINX 能否添加P3P头,如何添加。

 

求实践性东东,提供demo 感谢。wiki 我也查了很多,就是不会设置阿。。。愚昧

杜鑫
编辑于2011-11-08
 
 
 
评论 (1)链接 • 2011-11-08 
 
  • 0 支持
    所以劝你还是通过程序设置吧,呵呵 – 何远伦 2011-11-09

可以
demo如下

  1. server
  2. {
  3. listen 80;
  4. server_name yourdomain;
  5. root /data/app/www/oa.kunlun.com/htdocs;
  6. userid          on;
  7. userid_name     nginx;
  8. userid_domain   yourdomain;
  9. userid_path     /;
  10. userid_expires  365d;
  11. userid_p3p      'policyref="http://www.w3.org/2001/05/P3P/p3p.xml", CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"';
  12. index  index.php index.html index.htm;
  13. location xxxx{
  14. yourlocation
  15. }
  16. }

配置好后使用curl -I 可以看到结果

小白
小白
1671
编辑于 2011-11-09
 
该答案已被锁定,无法对其进行评论,编辑及投票。
()
 
评论 (1)链接 • 2011-11-09
 

看了很多,确实只有ngx_http_userid_module模块提到了nginx设置p3p,安装一下应该是能达到目的 http://wiki.nginx.org/HttpUserIdModule

不过建议还是通过程序来添加更方便一些:

ASP直接在头部加了头部申明:
<%Response.AddHeader "P3P", "CP=CAO PSA OUR"%>

php直接设置header:
header('P3P: CP=CAO PSA OUR');

JSP:
response.setHeader("P3P","CP=CAO PSA OUR")

ASP.NET
通过在代码上加Response.AddHeader("P3P", "CP=CAO PSA OUR")或者在Window服务中将ASP.NET State Service 启动。

该答案已被锁定,无法对其进行评论,编辑及投票。
()
 
评论 (0)链接 • 2011-11-08
 

查了一下资料,nginx0.8.20的升级文档说这之后的版本只要不设置都不会隐藏p3p和setcookie的header。

nginx 0.8.20的更新日志:http://linux.cn/thread/1000/1/1/

Bugfix: the "Set-Cookie" and "P3P" FastCGI response header lines were not hidden while caching if no "fastcgi_hide_header" directives were used with any parameters.

另附nginx关于p3p的介绍:
http://wiki.nginx.org/HttpUserIdModule

希望对你有帮助。

原文地址:https://www.cnblogs.com/lexus/p/3595619.html