I cannot use a variable in `fastcgi_pass` directive

PHPst asked:

I cannot use a variable for fastcgi_pass directive as below

fastcgi_pass $image:9000;

I get the following error.

 2020/07/07 01:39:08 [error] 27#27: *1 no resolver defined to resolve php, client:, server: , request: "GET /info.temp.php HTTP/1.1", host: ""

The $image variable has a valid value and if I hard code the value instead of the variable it will start to work.

Any workaround or fix please?

My answer:

The documentation states:

Parameter value can contain variables. In this case, if an address is specified as a domain name, the name is searched among the described server groups, and, if not found, is determined using a resolver.

You need to have a resolver configured because the value didn’t match any of your defined upstream servers.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.