variable map for fastcgi_pass

Kyle Sloan kyle at ifsight.com
Mon Sep 25 21:16:58 UTC 2017


Thanks for the response.  Both the variables respond/work when they are not maps/variables and just set.  I will try out the resolver and see if I can make any progress with it.

Kyle Sloan
DevOps Engineer | Interpersonal Frequency
kyle at ifsight.com
https://ifsight.com

> On Sep 25, 2017, at 4:13 PM, Sergey Kandaurov <pluknet at nginx.com> wrote:
> 
>> 
>> On 25 Sep 2017, at 22:12, Kyle Sloan <kyle at ifsight.com> wrote:
>> 
>> Hello,
>> 
>> I am trying to use a MAP function based on HOSTNAMES to determine if this domain should fastcgi_pass to a php5 or php7 container, but am having problems.
>> 
>> My map looks like
>> 
>> map $host $php_proxy_container {
>>  hostnames;
>> 
>>  default "php5fpm:9000";
>> 
>>  www.example.com    "php7fpm:9000";
>> }
>> 
>> 
>> My fastcgi file looks like
>> 
>>  fastcgi_pass   $php_proxy_container;
>> 
>> 
>> [..]
>> 
>> I get a generic 502 bad gateway, and nothing more in the http log.  Changing the fastcgi_pass line to the exact value in the map and restarting does work.
>> 
> 
> If variable used within fastcgi_pass evaluates to something like
> hostname:port, you need to define resolver to resolve that name.
> http://nginx.org/r/resolver <http://nginx.org/r/resolver>
> 
> OTOH, if that name is used within fastcgi_pass literally,
> it would be resolved at startup by system resolver instead.
> 
> -- 
> Sergey Kandaurov
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org <mailto:nginx at nginx.org>
> http://mailman.nginx.org/mailman/listinfo/nginx <http://mailman.nginx.org/mailman/listinfo/nginx>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170925/0aef960e/attachment-0001.html>


More information about the nginx mailing list