Need help to configure nginx-varnish-php

Hi All,

     I am newbie to nginx and would need help configuring

nginx-varnish-php-fpm setup to allow hitting specific php nodes for

     Our current setup.

   Nginx Varnish running in same server
   Php-fpm running on different server.

  Varnish is configured to load balance between php-nodes.

  We would like to find a way to access specific php-nodes on demand

instead of getting through the load balancer, is there a way we can do
that with the following setup. This is more of troubleshooting purpose
so we dont want to remove varnish load balancing.

 I am thinking something like when the request to nginx comes as a

specific url it hits specific php node.

$ cat /etc/nginx/conf.d/upstreams.conf
upstream php-be {



location ~* .php$ {
add_header Access-Control-Allow-Origin “*”;

include                       fastcgi_params;
fastcgi_index                 index.php;

fastcgi_split_path_info       ^(.+\.php)(/.+)$;
fastcgi_param SERVER_PORT     $forwarded_server_port;
fastcgi_param PATH_INFO       $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REMOTE_ADDR     X.X.X.X;
fastcgi_param HTTPS           $using_https;

fastcgi_pass                  php-be;



Any help would be greatly appreciated.


On Tue, 2015-02-03 at 23:26 +0100, Rajesh Gangula wrote:

  Varnish is configured to load balance between php-nodes.

fastcgi_param SERVER_PORT     $forwarded_server_port;

Any help would be greatly appreciated.


Untested but off the top of my head…

If you want to use a specific backend for a specific URL, then I’d
configure upstream definitions for all of them separately, and then set
a map up to define a variable containing the name of which one to
fastcgi_pass to.

( You could define the default to a separate upstream definition that
connects to them all in a load balanced manner? )

I would also put as many of those fastcgi_params into an include file as
possible - makes the config easier to understand.


Steve H. BSc(Hons) MIITP

Skype: sholdowa