A
A
Alexander Urich2019-11-08 09:51:13
PHP
Alexander Urich, 2019-11-08 09:51:13

How to proxy requests from nginx to php-fpm which is on another server?

There is an internal network in which there are several virtual machines. One of these virtual machines is an nginx proxy in front of several sites on other virtual machines that run on nginx. There are no problems with this, but I want nginx to proxy directly to fpm to another server. How to correctly config nginx in this case?
For example:
nginx is on a server with internal ip 192.168.0.1
php-fpm is on a server with ip 192.168.0.2
On fpm is the site mysite.ru in the directory /var/www/mysite.ru

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fixid, 2019-11-08
@Fixid

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question