Map FastCGI Ports Dynamically
Valentin V. Bartenev
ne at vbart.ru
Thu Feb 23 09:53:58 UTC 2012
On Thursday 23 February 2012 05:28:04 justin wrote:
> Valentin,
>
> Ok, well I am almost there. The problem is since we need to define the
> map block outside of server, the $user variable is not defined yet.
> I.E.
>
> http {
> # $user is not defined yet, it comes from inside server {}
> map $user $user_fastcgi_port {
> default 9000;
> justin 9001;
> simon 9002;
> }
> }
>
> server {
> # Set's $user
> server_name ~^(?<user>.+)\.my\.domain\.com$;
> }
>
Did you try, or it's just your guess? There's no "variable scope" concept in
nginx configuration. And it mostly has declarative nature, therefore, the order
of most directives is not important, unless it is specifically documented.
btw, your example config also wrong. If look at the documentation, you will see:
server
syntax: server { ... }
default: —
context: http
http://nginx.org/en/docs/http/ngx_http_core_module.html#server
wbr, Valentin V. Bartenev
More information about the nginx
mailing list