You do not need to use proxy_ directives because they work with the HTTP protocol, but in this case the FastCGI protocol is used. Also, as the comments said, there is no need for an if because the Nginx server cannot determine if the file exists on the remote server.
You can try this configuration:
location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; # Mitigate https://httpoxy.org/ vulnerabilities fastcgi_param HTTP_PROXY ""; fastcgi_read_timeout 150; fastcgi_buffers 4 256k; fastcgi_buffer_size 128k; fastcgi_busy_buffers_size 256k; fastcgi_pass 192.168.x.xx:9000;
You will need to replace /path/to/site/root with the real path on the PHP-FPM server. For example, if the request http://example.com/some/file.php be processed by /var/www/some/file.php , then set it like this:
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
In addition, so that the PHP-FPM server can receive requests from outside, edit the configuration of the FPM pool (on Debian it is usually located in /etc/php5/fpm/pool.d/www.conf , on Centos - /etc/php-fpm.d/www.conf ):
Replace
listen = 127.0.0.1:9000
with:
listen = 9000
or
listen = 192.168.x.xx:9000
You will probably also need to edit the allowed_clients directive:
listen.allowed_clients = 127.0.0.1,192.168.y.yy # Nginx server IP
I also need to configure nginx to serve static files from the same server
If I understand correctly and you want to serve static files from the server, Nginx works, you can simply add another location to your Nginx configuration.
source share