Answer the question
In order to leave comments, you need to log in
How to set up nginx for two sites with few rules?
Task: at the address domen.ru we display a site from the directory /var/www/domen.ru
And at the address domen.ru/api we display another site on the same server located in /var/www/site.ru
everything would be fine if if it were just a directory or a direct address, and this is an argument in the query string.
The difficulty for me is that site.ru has such rules in nginx and I don’t quite understand how to correctly pass the arguments:
server_name site.ru;
location / {
root /var/www/site.ru;
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
server_name domain.ru;
location /api/ {
root /var/www/site.ru;
index index.php index.html;
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question