Last active
December 26, 2023 01:35
-
-
Save sanmai/10341223 to your computer and use it in GitHub Desktop.
Hide referer header for outbound links with the power of nginx. For this to work you must use it within a https-enabled server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# https://www.example.com/hide-referer?http://en.wikipedia.org/wiki/HTTP_referer | |
server { | |
server_name www.example.com; | |
listen 80; | |
listen 443 ssl; | |
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; | |
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; | |
# ssl_... etc | |
location = /hide-referer { | |
if ($args = "") { | |
return 404; | |
} | |
# only works over https | |
if ($ssl_session_id = "") { | |
return 404; | |
} | |
add_header X-Robots-Tag "noindex, nofollow"; | |
add_header Content-Type "text/html; charset=us-ascii"; | |
add_header Refresh "1; url=$args"; | |
return 200 "<title></title><style>html,body{margin:0;min-height:100%;background:url(https://www.google.com/images/loading.gif) center no-repeat;}</style><body>"; | |
} | |
# and so forth | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks you