Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Referrer Policy with nginx

My CMS(https) and image server(http) is separate. 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? I have found giving this html meta tag in the html will display the images.

<meta name="referrer" content="origin">

but is it possible to do this without editing each html page and do this server side? I am on Nginx v1.10.2

like image 210
Maca Avatar asked Apr 17 '17 07:04

Maca


People also ask

How to set referrer Policy in Nginx?

Referrer-Policy By checking the referrer, the new webpage can see where the request originated. The Referrer-Policy can be configured to cause the browser to not inform the destination site any URL information. Next, restart the Apache service to apply the changes. Next, restart the Nginx service to apply the changes.

How set CSP header in nginx?

nginx Example CSP HeaderInside your nginx server {} block add: add_header Content-Security-Policy "default-src 'self';"; Let's break it down, first we are using the nginx directive or instruction: add_header . Next we specify the header name we would like to set, in our case it is Content-Security-Policy .

What is Add_header in nginx?

The Nginx add_header directive allows you to define an arbitrary response header and value to be included in all response codes, which are equal to 200 , 201 , 204 , 206 , 301 , 302 , 303 , 304 , or 307 . This can be defined from within your nginx.


1 Answers

Simply adding below solved my issue.

add_header 'Referrer-Policy' 'origin';
like image 154
Maca Avatar answered Sep 28 '22 04:09

Maca