Created
October 14, 2023 16:25
-
-
Save cloudrck/9ee28c90555c3921cd0fcdf1d6b561eb to your computer and use it in GitHub Desktop.
Nginx Secure Link Config
This file contains 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; | |
root /var/www/; | |
server_name test01.cloudrck.net www.test01.cloudrck.net; | |
location /p { | |
if ($request_uri ~* "^/p/(.+)/([0-9]+)/(.*)$") { | |
set $md5 $1; | |
set $expires $2; | |
set $directory $3; | |
} | |
if ($md5 = "") { | |
add_header X-debug-message "md5 empty"; | |
return 200; | |
} | |
if ($expires = "") { | |
add_header X-debug-message "$md5 - expires empty"; | |
return 200; | |
} | |
if ($directory = "") { | |
add_header X-debug-message "$md5 $expires - directory is empy"; | |
return 200; | |
} | |
add_header X-debug-message "$md5-$expires-$directory"; | |
#return 200; | |
#proxy_pass "http://wsl.host/$3?md5=$1&expires=$2"; | |
rewrite "^/p/(.+)/([0-9]+)/(.*)$" /$3?md5=$1&expires=$2 last; | |
} | |
location /secure { | |
if ($request_uri ~* "^/p/(.+)/([0-9]+)/(.+)/(.*)$") { | |
set $directory $3; | |
} | |
add_header X-debug-secure "$directory"; | |
secure_link $arg_md5,$arg_expires; | |
secure_link_md5 "$secure_link_expires$directory secret"; | |
if ($secure_link = "") { | |
return 200; | |
} | |
if ($secure_link = "0") { | |
return 410; | |
} | |
} | |
location /secure1 { | |
secure_link_secret secret; | |
if ($secure_link = "") { | |
return 403; | |
} | |
rewrite ^ /securelink/$secure_link; | |
} | |
location /securelink { | |
internal; | |
root /var/www; | |
} | |
location /public { | |
root /var/www; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment