我该如何操作nginx变量字符串

时间:2016-11-07 21:01:07

标签: nginx nginx-location

我正试图操纵一个nginx变量。

我有一个变量名$ user,其中包含UPN,如someone@example.com 我想设置另一个变量$ xuser;成为$ user减去@domain - 即某人。

这是在一个位置块中完成的,所以我认为我不能使用map。

我试过这个,但$ xuser似乎永远不会被设置:

calc-col some-agent [ [] -> set pcolor grey ]

1 个答案:

答案 0 :(得分:2)

您可以在' http'中使用地图块。

http://nginx.org/en/docs/http/ngx_http_map_module.html

map $user $xuser {
  ~^(\w+)@example.com $1;
  default '';
}