Need help to configure nginx-varnish-php s

Steve Holdoway steve at greengecko.co.nz
Tue Feb 3 23:19:46 UTC 2015


On Tue, 2015-02-03 at 23:26 +0100, Rajesh Gangula wrote:
> Hi All,
> 
>          I am newbie to nginx and would need help configuring
> nginx-varnish-php-fpm setup to allow
> 
>          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 {
> 
>   server php-vip.prod..com:9001;
> 
> }
> 
> 
> 
> 
> 
>  ==================
>    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.
> 
> Thanks
> -Rajesh
> 
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
-- 
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa



More information about the nginx mailing list