Answer the question
In order to leave comments, you need to log in
How to configure nginx to handle different routes with different fastcgi?
I read about how location works , but for some reason, when going to sub.site.local/hotels , " location / {} " is still processed , and not " location / hotels {} ", although the hotels prefix is longer.
How to send requests to different php-fpm?
Current config:
server {
listen 80;
server_name sub.site.local;
index index.php;
client_max_body_size 100M;
fastcgi_read_timeout 1800;
location /hotels {
root /projects/newsite/public;
try_files $uri $uri/ /index.php?$query_string;
add_header X-location newsite;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass cabinet:9000;
}
location / {
root /projects/oldsite;
try_files $uri $uri/ /index.php?$query_string;
add_header X-location oldsite;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass agent:9000;
}
}
Answer the question
In order to leave comments, you need to log in
Knock on the door
In the config:
server_name sub.site.local
And you climb site.local/hotels
I advise you to add access_log to locations. To determine exactly which location the request goes to. After proper configuration, the main thing is not to forget to remove them.
Headers can get into the cache, they are more difficult to determine.
According to this config, when requesting sub.site.local/hotels, nginx should execute the /projects/newsite/public/hotels/index.php file in fastcgi , if it exists.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question