lundi 22 octobre 2018

Different root locations for nginx php-fpm

I'm trying to get current schema to work:

server {

location / {
    try_files $uri =404;
    }

location ~ ^/server-api(.*)$ {
    try_files $uri =404;
    root /code/server-api/web;
    index app.php;
    fastcgi_index app.php;
    fastcgi_pass php:9000;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}


location ~ ^/chat-api(.*)$ {
    try_files $uri =404;
    root /code/chat-api/web;
    index app.php;
    fastcgi_index app.php;
    fastcgi_pass php:9000;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}}

It does do matching based on the path, but then nothing happens.

So, basically what do I want to achieve - it's going to be a nginx docker container with forwarded port to my localhost and when I hit curl localhost:8080/server-api/ and curl localhost:8080/chat-api/ nginx will process it as server-api/web/app.php and chat-api/web/app.php respectively, hence give me a processed by php-fpm reply.(fpm lives in another container and linked via tcp). Would appreciate any help/tips or tricks. I'm using nginx 1.14.0 and php 7.0/7.2. Thank you!




Aucun commentaire:

Enregistrer un commentaire