In a nginx configuration file, how to define a fastcgi_param that contains the "$" sign?
I'm trying to define a few environment variables for a PHP application but one of these variables contains the "$" sign. When I test the configuration file with nginx -t
, I get an error message telling me that a variable does not exist. It seems to interpret the text after "$" as a variable name, which is of course not defined.
Maybe I did not search in the right places, but I couldn't find information about how to escape the "$" character. Is that possible and how can it be done?
Update: I tried to enclose the value between single quotes and double quotes following d3ag0s's comment but I had the same error message.
According to this page, it is not possible to escape the $ sign, but they provide a workaround:
https://openresty.org/download/agentzh-nginx-tutorials-en.html#nginx-variables-escaping-dollar
geo $dollar {
default "$";
}
server {
listen 8080;
location /test {
echo "This is a dollar sign: $dollar";
}
}
Although it might not be the best solution, I have tested it and it works.