# 加固 Referrer-Policy 头部

**URL:** <https://meta.discourse.org/t/harden-referrer-policy-header/100172>\
**Category:** Feature\
**Created:** [2018 年10 月 22 日 15:01 UTC](https://meta.discourse.org/t/harden-referrer-policy-header/100172 "2018-10-22T15:01:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)\
发布日期： [2018 年10 月 22 日 15:01 UTC](https://meta.discourse.org/t/harden-referrer-policy-header/100172/1 "2018-10-22T15:01:07Z")

</div>

## Feature

Make `Referrer-Policy: strict-origin-when-cross-origin` the default header.

Please change the default `Referrer-Policy header` to `strict-origin-when-cross-origin` that also covers the use-case of `no-referrer-when-downgrade` but works for e.g., comments embedding.

## Situation

[https://securityheaders.com/?q=https%3A%2F%2Fmeta.discourse.org&hide=on&followRedirects=on](https://securityheaders.com/?q=https%3A%2F%2Fmeta.discourse.org&hide=on&followRedirects=on)

… show that “There was a duplicate Referrer-Policy header.”

1. `Referrer-Policy strict-origin-when-cross-origin`
2. `Referrer-Policy no-referrer-when-downgrade`

Only one of those should be set. 1 is not referenced in Discourse’s code, but it seems to me the legitimate one to use since it acts as a superset of 2. 2 is referenced in the sample nginx configuration file at

> <https://github.com/discourse/discourse/blob/99d1ded3b3a2767617bbee9824e93eb57f135864/config/nginx.sample.conf#L264>

In discourse\_docker:

```plaintext
root@ps /var/discourse # grep -i referrer templates/*.yml
templates/web.ssl.template.yml: from: /add_header Referrer-Policy 'no-referrer-when-downgrade';/m
templates/web.ssl.template.yml: add_header Referrer-Policy 'no-referrer-when-downgrade';

```

## What to do with it?

1. change line 264 of `config/nginx.sample.conf` in discourse
2. update the `web.ssl.template.yml` to match the change in discourse\_docker.

---

_[View the full topic](https://meta.discourse.org/t/harden-referrer-policy-header/100172)._
