Disclaimer: I'm not a sys admin :)
I have the following setup: - react pwa in /var/www/react/build - php application under /var/www/html - site url mysite.loc I want all requests except mysite.loc/fapi/* and mysite.loc/api/* to be handled by react app and (fapi|api)/* by php app.
I am trying with the following nginx config:
server { listen 80; listen [::]:80; server_name mysite.loc; root /var/www/react/build; index index.html index.php; location ^~ /fapi { rewrite ^/fapi/?(.*)$ /html/fapi/$1 last; } location ^~ /api { rewrite ^/api/?(.*)$ /html/api/$1 last; } location ^~ /html { index index.php; root /var/www; try_files $uri $uri/ /index.php$is_args$args; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 300; } } }
when accessing mysite.loc/fapi/user/get this config returns the following error: "/var/www/react/build/index.php" failed (2: No such file or directory)
what I was expecting was that the nginx would send request to /var/www/html/fapi/index.php. Not ideal but something I can work with.. Ideally I would like the request to go to /var/www/html/index.php, request being /fapi/user/get.
Can you point me into the right direction? Thanks.