6

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
Chad DeWitt
  • 61
  • 1
  • 3
  • This works well; Please see https://stackoverflow.com/questions/60827630/nginx-sub-filter-javascipt-replace-string-containing/73642525#73642525 Thanks, Pete – Pete Sep 08 '22 at 00:10

1 Answers1

8

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};
}
Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35