fastcgi – Nginx multiple location with php-fpm


Sorry for this question if it was duplicated or already provided a solution before. However, I tried to keep myself stuck for a day.
Currently, I have my nginx reverse proxy that performs a proxy to 3 local php servers and a remote server.
The three locals are already defined by another person, but I now have to add a new remote control with a new location. Here is my config nginx

 server {
listen 443 ssl http2 default_server;

root    /var/www/;
ssl things...

location / {
    root /var/www/html;
    index   index.php index.html index.htm;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page  404              /404.html;
    location = /404.html {
    root   /var/www/html;
}
error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   /var/www/html;
}

location /itop/ {
    index   index.php index.html index.htm;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /asset {
    alias /var/www/asset/public;
    try_files $uri @asset;
    location ~ .php {
        fastcgi_pass 127.0.0.1:9005;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }
}
location @asset {
    rewrite /asset/(.*)$ /asset/index.php?/$1 last;
}
location /hrm {
root /var/www/hrm;
rewrite  ^/hrm/(.*)$ /$1 break;
    try_files $uri @hrm;
}

location @hrm {
    fastcgi_pass 127.0.0.1:9005;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/hrm/symfony/web/index.php;
fastcgi_param SCRIPT_NAME /hrm/symfony/web/index.php;
fastcgi_param REQUEST_URI /hrm$uri?$args;
}

location ~ .php$ {
    fastcgi_pass   127.0.0.1:9005;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
}


 location ^~ /vcms {
    rewrite ^/vcms/?(.*)$ /vcms/public/$1 last;
       add_header X-debug-message "vcms1" always;
}

location ^~ /vcms/public {
    add_header X-debug-message "vcms2" always;

    try_files $uri $uri/ /vcms/public/index.php?q=$uri&$args;
    index index.php index.html index.htm;

    root /usr/share/nginx/hd-cmv2/public;#i mounted with nfs from this nginx to the remote php server
    location ~* .php(/|$) {
    rewrite /vcms/public/(.*)$ /$1 break;

    try_files $uri =404;

    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass my_remote_phpserver:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

My problem is mm trying to proxy the location / vcms on the remote php server, my nginx configuration seems to be using the php remote proxy server because the log from the remote php-fpm reads "12 / Oct / 2019 : 08: 49: 00 +0700 "GET /index.php" 404 ".
I also have a standalone vcms proxy that only proxies for this php-fpm server which also works fine. However, for a particular reason, I want to add it to the nginx multiple location above. Here is my standalone configuration of nginx for vcms.

 location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?q=$uri&$args;
            #try_files $uri $uri/ =404;
    }

location ~ .php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass 10.10.11.251:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
}

If I put the above configuration applies to the multiple nginx proxy, I would have the error that every time I access / vcms, I would have the error "impossible to read upstream, fastcgi_pass to my 127.0 .0.1: 9005 local ", so my best bet was to have the / vcms / public file that could replace php-fpm with a proxy, but still not working and getting 404.

I do not know if my nginx configuration has a problem or it's missing something at php-fpm / www.config (but the stand-alone proxy for vcms works fine), or if I have a problem with the existing configuration of nginx.
Thank you for reading my question