Created
December 25, 2020 09:54
-
-
Save Danukeru/024ef78628a478f506b8dd3787f90de5 to your computer and use it in GitHub Desktop.
NGINX sha256 path matching file directory
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
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