[英]How to set Referrer Policy with nginx
My CMS(https) and image server(http) is separate.我的 CMS(https) 和图像服务器 (http) 是分开的。 I have setup my image server so that it only can serve to whitelisted referrer pages.我已经设置了我的图像服务器,以便它只能服务于列入白名单的引荐来源网页。 Now my issue is how do I allow the CMS server to send response header to the image server so the CMS can display the images?现在我的问题是如何允许 CMS 服务器将响应 header 发送到图像服务器,以便 CMS 可以显示图像? I have found giving this html meta tag in the html will display the images.我发现在 html 中给出这个 html 元标记将显示图像。
<meta name="referrer" content="origin">
but is it possible to do this without editing each html page and do this server side?但是是否可以在不编辑每个 html 页面并在服务器端执行此操作的情况下执行此操作? I am on Nginx v1.10.2我在 Nginx v1.10.2
简单地在下面添加解决了我的问题。
add_header 'Referrer-Policy' 'origin';
You actually dont need quotes on Refferer-Policy if you add the line into default.conf.如果将该行添加到 default.conf 中,则实际上不需要引用 Refferer-Policy。
add_header Referrer-Policy 'origin'
Here you can also see other values https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy在这里您还可以看到其他值https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
location / {
add_header 'Referrer-Policy' 'unsafe-url';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.