OrkoGrayskull inquires about changing the Referrer-Policy header from the default strict-origin-when-cross-origin to same-origin in a self-hosted Discourse instance. They note that the setting is managed by Rails/Rack rather than Nginx and share extensive grep results showing the default policy is hardcoded across various Ruby gems and initializers within the container. After RGJ suggests an Nginx workaround using proxy_hide_header and add_header, OrkoGrayskull dismisses it as a “nasty hack” and asks for the correct production location to modify the setting. Kianga proposes a less invasive alternative: adding a <meta name="referrer" content="same-origin"> tag within a custom theme component’s HTML head. While this method does not remove the HTTP header, Kianga reports that testing via whatsmyreferer.com indicates it successfully prevents referrer data from being sent on outgoing links.
Yeah. Stupid. I was not searching at the right place.
I found many entries of Referrer-Policy' => 'strict-origin-when-cross-origin'
Here is a list (grep strict-origin-when-cross-origin /var/www/discourse/ -R):
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.2/lib/rack/protection/referrer_policy.rb: # referrer_policy:: The policy to use (default: ‘strict-origin-when-cross-origin’)
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-protection-3.0.2/lib/rack/protection/referrer_policy.rb: # referrer_policy:: The policy to use (default: ‘strict-origin-when-cross-origin’)
A slightly less nasty hack is putting this in the HTML head part of a custom theme component:
<meta name="referrer" content="same-origin">
That doesn’t remove the HTTP header, and I couldn’t find any definitive info if the HTTP header overwrites the HTML meta tag or the other way around, but at least according to a quick test with whatsmyreferer.com, it seems to work: no more referrer header is sent on outgoing links.