Reputation: 1
How to match all files with or without extension, except those with the extension txt, pdf, jpeg.
On my Nginx configuration this downloads all the files without any restriction.
location ~ .+(?<!\.pdf|\.txt|\.jpeg)$ {
auth_request /auth.php;
error_page 401 = @login;
}
Thanks
Upvotes: 2
Views: 692
Reputation: 1
Solved I auth.php was not included as an exception which would cause a loop.
location ~ .+(?<!/|auth.php|.txt|.pdf|.jpeg|.jpg|.png)$ {
auth_request /auth.php;
error_page 401 = @login;
}
Upvotes: 1
Reputation: 3178
What about defining two locations? E.g.
location ~ \.(pdf|txt|jpeg)$ {
# handle those with the extension pdf, txt, jpeg
}
location / {
# handle all files with or without extension
}
Upvotes: 0