Answer the question
In order to leave comments, you need to log in
Write a rule for location in nginx?
Good afternoon,
There is the following folder structure for the main host in nginx (/usr/share/nginx/www/):
install1/
-- app
-- config
-- data
install2/
-- app
-- config
-- data
installN/
-- app
-- config
-- data
other/
We need to write a rule for nginx that will block access to the app/ , config/ and data/ subfolders of each folder at the top level.
The current rule is this: location ~* /app/ { deny all; }
but it blocks the app folder at any level, not just the second.
How to make the rule correct?
Answer the question
In order to leave comments, you need to log in
location ~ ^/install(\d+)/(app|config|data)/ {
deny all;
}
~
- case sensitive ^
- the beginning of the line (\d+)
- one or more digits (app|config|data)
- matches app or config or data Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question