Wiki / Security headers
Warning: Referrer-Policy
The site does not say how much of its page address to reveal to other sites when a visitor follows a link. The risk is small: modern browsers pass only the domain to other sites even without the header.
What it does not mean. It does not mean addresses with parameters are leaking now. Since November 2020 the standard applies strict-origin-when-cross-origin when no policy is given. The header matters for older browsers and for behaviour that does not depend on the browser.
- In our report
- Warning (yellow), category weight 1.0 of 2.0
- Time to fix
- 5 minutes
- Can it break things
- Not with the default value. With
no-referrer, analytics suffer
How to fix it
nginx (tested on 1.26.3)
add_header Referrer-Policy "strict-origin-when-cross-origin" always;Apache (tested on 2.4.59, also works in .htaccess)
Header always set Referrer-Policy "strict-origin-when-cross-origin"Without server access
<meta name="referrer" content="strict-origin-when-cross-origin" />Works from the page <head>. A single link can carry referrerpolicy="no-referrer".
How to check
curl -sI https://example.com | grep -i referrer-policyExpected
referrer-policy: strict-origin-when-cross-origin
What can break
- With
no-referrerorsame-origin, affiliate and advertising systems no longer see that the visitor came from you. If you earn commission that way, check before changing. - Some payment and sign-in systems check where a request came from. With
no-referrerthey may reject a returning visitor.
Possible values
| Value | What it passes on | When to choose it |
|---|---|---|
strict-origin-when-cross-origin | Full address within your site; domain only to others; nothing from HTTPS to HTTP | The browser default; right for almost everyone |
same-origin | Nothing to other sites | When addresses carry sensitive data (order numbers, tokens) |
no-referrer | Nothing to anyone, including yourself | The strictest; internal navigation disappears from analytics |
origin | Domain only, to everyone | Rarely needed |
unsafe-url | Full address to everyone, even from HTTPS to HTTP | Do not use |
Sources
- W3C: Referrer Policy
- MDN (Mozilla): Referrer-Policy header
- nginx documentation: add_header
- Apache documentation: mod_headers
Changes
- Page published; nginx and Apache lines tested on a test server.
