I'm developing an application composed of 3 microservices. Each microservice is a Symfony 4 application.
To route all my request made to this application I'm using Nginx.
There are, for now, three url patterns, one for each microservice. One of them is the ^/auth pattern which allow the access to the authentication API through the php-fpm upstream.
I've tried many things but for now this is the closest Nginx configuration I have from my objective.
server {
listen 80;
server_name app.local;
root /app;
# location directive for the authentication API
location ~ ^/auth/ {
root /app/public;
fastcgi_pass auth_api_upstream;
fastcgi_split_path_info ^(/auth)(/.*)$;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php$fastcgi_path_info;
include fastcgi_params;
}
# ....
# return 404 if other location do not match
location / {
return 404;
}
}
With this configuration, this is what append :
While Nginx is handling the request :
So my questions are :
Thank you for your answers :)
Try to move the include fastcgi_params; line upward
something like this:
server {
listen 80;
server_name app.local;
root /app;
location ~ ^/auth/ {
root /app/public;
set $app_entrypoint /index.php;
fastcgi_pass auth_api_upstream;
fastcgi_split_path_info ^(/auth)(/.*)$;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param DOCUMENT_URI $app_entrypoint;
fastcgi_param REQUEST_URI $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $app_entrypoint;
fastcgi_param SCRIPT_FILENAME $document_root$app_entrypoint;
}
# return 404 if other location do not match
location / {
return 404;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With