nginxreferernginx-config

invalid_referer syntax for if in nginx


I use this in my nginx.conf where ${WWW_URL} is variable with my web app url

location ~* \.(jpg|png)$ {
    valid_referers none blocked www.${WWW_URL} ${WWW_URL};

    if ($invalid_referer) { # line 63
        return 403;
    }
}

But when I start nginx I got

[emerg] invalid condition ")" in /etc/nginx/nginx.conf:63

I try to change the indent, delete space ... what is the issue on this if statement ?

Thanks


Solution

  • envsubst is probably removing $invalid_referer from if ($invalid_referer) {

    nginx: [emerg] invalid condition ")" in /etc/nginx... is the error returned for empty brackets in an if condition