Skip to content

Instantly share code, notes, and snippets.

@statico
Last active September 24, 2023 12:15
Show Gist options
  • Save statico/14fa84d7e79722031d5e49694191ba1d to your computer and use it in GitHub Desktop.
Save statico/14fa84d7e79722031d5e49694191ba1d to your computer and use it in GitHub Desktop.
Ian's Personal Short Link Bookmark Service
# From https://stackoverflow.com/questions/29354142/nginx-how-to-mass-permanent-redirect-from-a-given-list
map $request_uri $statico_link {
include /home/ian/links.conf;
# Allow hyphens for readability
~^/(.+)-(.+)$ /$1$2;
~^/(.+)-(.+)-(.+)$ /$1$2$3;
~^/(.+)-(.+)-(.+)-(.+)$ /$1$2$3$4;
}
server {
listen 443 http2;
listen [::]:443 http2;
server_name statico.link;
root /var/www/html;
ssl on;
ssl_certificate /etc/letsencrypt/live/statico.link/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/statico.link/privkey.pem;
include /etc/nginx/cipherlist;
include /etc/nginx/letsencrypt;
add_header Referrer-Policy unsafe-url;
add_header X-Robots-Tag "noindex, nofollow";
if ($statico_link) {
return 302 $statico_link;
}
location / { return 302 https://langworth.com/; }
location /all-links.txt {
alias /home/ian/links.conf;
add_header Content-Type text/plain;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment