Answer the question
In order to leave comments, you need to log in
How to restrict access to /user on a server with nginx in Drupal?
Hello.
There is a VPS server with nginx + php-fpm. It has a Drupal site. When defining location / user in its config, it gives a 404 error. And the error appears regardless of what I write in it (albeit empty).
Here's how I do it:
location /user {
allow 111.111.11.11;
deny all;
include /etc/nginx/conf.d/php.conf; #тут подключаю php
}
location /admin {
allow 111.111.11.11;
deny all;
include /etc/nginx/conf.d/php.conf; #тут подключаю php
}
Answer the question
In order to leave comments, you need to log in
This is because you don't understand how try_files and rewrite work. Nginx tries to find the user folder in the root of the site. It is not in Drupal by default and it is directly written about this "2: No such file or directory". There are no other rules that would match or rewrite the url up to /index.php?q=user in the "allow" cases, so don't get around to launching Drupal. All you have to do is do this and it will work :
location /user {
allow 111.111.11.11;
deny all;
try_files $uri /index.php?$query_string;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question