Arbitrarily slicing $server_name into subdomains?
Igor Clark
lists at ruby-forum.com
Sun Jan 10 00:03:42 MSK 2010
Thanks Tobia. That makes sense, though it makes the obsessive tidier
inside me a bit uncomfortable ;-)
It would be great to be able to do a real arbitrary list, I wonder if
there's a way to do that?
cheers
Igor Clark
Tobia Conforto wrote:
> Igor Clark wrote:
>> url: http://client.myserver.net/
>> root: /var/www/docs/myserver.net/client/public
>>
>> url: http://project.client.myserver.net/
>> root: /var/www/docs/myserver.net/client/project/public
>>
>> url: http://sub.project.client.myserver.net/
>> root: /var/www/docs/myserver.net/client/project/sub/public
>> (etc.)
>
> In this case, a smarter regexp is enough:
>
> server_name ~ ^([^.]+\.)?([^.]+\.)?([^.]+\.)?([^.]+\.)?myserver\.net$;
> root /var/www/docs/myserver.net/$4/$3/$2/$1/public;
>
> Add as many ([^.]+\.)? blocks as you need. This works because
> /var/www/docs/myserver.net/////public is a valid UNIX path, equivalent
> to /var/www/docs/myserver.net/public
>
> -Tobia
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list