Skip to content

Instantly share code, notes, and snippets.

@jyntran
Last active August 11, 2020 12:55
Show Gist options
  • Save jyntran/32e97587b0c718ff03e0aed184a1dfe3 to your computer and use it in GitHub Desktop.
Save jyntran/32e97587b0c718ff03e0aed184a1dfe3 to your computer and use it in GitHub Desktop.
Nginx disable hotlinking and error pages
server {
server_name site.jyntran.ca
root /var/www/html
location / {
try_files $uri $uri/ =404;
}
location /assets/ {
# custom error page
error_page 403 /403.html;
# disable direct linking
valid_referers server_names *.jyntran.ca;
if ($invalid_referer) {
return 403;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment