nginx set directive not working
I'm facing the same issue as described in How to force nginx to resolve DNS (of a dynamic hostname) everytime when doing proxy_pass? and thus wanted to apply the same solution.
My NginX, version 1.15.2, config now looks like this:
server {
resolver 127.0.0.1;
set $backend "http://dynamic.example.com:80";
proxy_pass $backend;
}
Upon starting, I see the following error message
[emerg] 11#11: invalid number of arguments in "set" directive in /etc/nginx/conf.d/default.conf:3
Any clues?
Solution 1:
The Nginx config itself was indeed correct.
The problem I had was envsubst also replacing the $backend variable with an empty space.