nginx upstream: pass directly to PHP-FPM on another server

5,055

Yes, you can. First you need to configure PHP-FPM to listen on an external IP instead of localhost, which is the default. Add/change the following in php-fpm.conf (on Ubuntu it's defined in /etc/php5/fpm/pool.d/www.conf):

listen = 9000

and restart PHP-FPM. Make sure that that port number is allowed by any firewalls between the load balancer and the app servers. The configure nginx to proxy to the app servers on that port number:

upstream php {
    server 192.168.0.10:9000;
    server 192.168.0.11:9000;
}

fastcgi_pass php;
Share:
5,055

Related videos on Youtube

baussman
Author by

baussman

Updated on September 18, 2022

Comments

  • baussman
    baussman over 1 year

    Background: 3 servers, 1 load balancer and 2 PHP app servers.

    Do I need to install nginx on the 2 app servers? Or can I pass directly from the load balancer to PHP-FPM running on the app servers?