map with two variables
Matthias Rieber
ml-nginx at zu-con.org
Mon Mar 9 15:36:00 UTC 2015
Hi,
I'd like to set a variable to the value of $host where the dots are
replaced by underscore. My first idea:
map $host $graphite_host {
"~(?P<a>[^.]*)\.(?P<b>[^.]*)\.(?P<c>[^.]*)" $a_$b_$c;
}
But I can't use more than one variable in the result. $a or $b would
work, but not $a_$b or $a$b. I always get an error like:
nginx: [emerg] unknown "a$b" variable. Is that intentional? Is there any
other way to replace the . by _?
# nginx -V
nginx version: nginx/1.7.10
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --with-http_stub_status_module
--with-http_ssl_module --prefix=/usr/local
--conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log
--add-module=/usr/local/src/ngx_devel_kit
--add-module=/usr/local/src/lua-nginx-module
--add-module=/usr/local/src/headers-more-nginx-module/
--add-module=/usr/local/src/nginx-statsd --with-http_spdy_module
--with-http_sub_module
Regards,
Matthias
More information about the nginx
mailing list