Skip to content

Instantly share code, notes, and snippets.

@Danukeru
Created December 25, 2020 09:54
Show Gist options
  • Save Danukeru/024ef78628a478f506b8dd3787f90de5 to your computer and use it in GitHub Desktop.
Save Danukeru/024ef78628a478f506b8dd3787f90de5 to your computer and use it in GitHub Desktop.
NGINX sha256 path matching file directory
server {
listen 80;
listen [::]:80;
server_name website.com;
access_log /var/log/nginx/website.access.log;
error_log /var/log/nginx/website.error.log;
client_max_body_size 20m;
location /folders {
set $lpc "ingenting";
if ($uri ~* "^/folders/([a-z,0-9]{64}/.*)" ) { # this tends to be constant time
set $lpc $2;
}
alias /var/www/folders/$lpc; # folder or symlink with sha256 as name contained here
autoindex on;
autoindex_format xml;
xslt_stylesheet /var/www/dirlist.xslt path='$uri';
}
location / {
root /var/www/html;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/html;
internal;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment