Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I escape $ in nginx variables

Tags:

nginx

ibm-bpm

I'm trying to map the BPM specific $WSSR header to the Host header in a nginx configuration and I continue to get "nginx: [emerg] unknown "wssn" variable " errors. How can I access this header value in a nginx configuration? Is there a way to escape the $ character?

Here is my current configuration to try to map the custom header and the host to a single value

map $http_\$wssn $x_host {
    default $host;
    "~." $http_\$wssn;
}

reloading my config with this map results in this error

# nginx -s reload
2019/08/12 18:37:42 [emerg] 25091#25091: unknown "wssn" variable
nginx: [emerg] unknown "wssn" variable
like image 775
Chad DeWitt Avatar asked Mar 03 '23 14:03

Chad DeWitt


1 Answers

As per agentzh-nginx-tutorials, the solution is a bit tricky. Since there is no way to escape dollar sign in NGINX variables, you have to make it a variable.

Totally untested, but maybe:

geo $dollar {
    default "$";
}

geo $foo {
    default "http_${dollar}wssn";
}

map ${dollar}${foo} $x_host {
    default $host;
    "~." ${dollar}${foo};
}
like image 74
Danila Vershinin Avatar answered Mar 31 '23 23:03

Danila Vershinin