Welcome! Log In Create A New Profile

Advanced

Arbitrarily slicing $server_name into subdomains?

Igor Clark
January 06, 2010 02:28PM
Hi there, hope all are well!

I'd like to match a wildcard DNS name, pointing to an nginx virtual
host, such that an arbitrary level of subdomains maps to an arbitrary
level of directories, in a manner I specify.

For example:

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.)

It's straightforward to do this for a fixed level of
subdomains/directories using a server_name regex, for example:

server_name ~^(.*)\.(.*)\.myserver\.net$;
set $my_host $2/$1;
root /var/www/docs/myserver.net/$my_host/public

which gives me project.client.myserver.net ->
..../myserver.net/client/project/... - but the whole point of using
wildcards like this is that I don't want to keep adding new configs.

Is it possible to do this, perhaps using the perl config module? Or
maybe just a smarter regex?

Very grateful for any suggestions.

Thanks,
Igor Clark
--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Arbitrarily slicing $server_name into subdomains?

Igor Clark January 06, 2010 02:28PM

Re: Arbitrarily slicing $server_name into subdomains?

Igor Clark January 06, 2010 02:46PM

Re: Arbitrarily slicing $server_name into subdomains?

Tobia Conforto January 08, 2010 10:34AM

Re: Arbitrarily slicing $server_name into subdomains?

Igor Clark January 09, 2010 04:10PM

Re: Arbitrarily slicing $server_name into subdomains?

merlin corey January 11, 2010 02:24PM

Re: Arbitrarily slicing $server_name into subdomains?

merlin corey January 11, 2010 02:26PM

Re: Arbitrarily slicing $server_name into subdomains?

Igor Clark January 14, 2010 05:36PM

Re: Arbitrarily slicing $server_name into subdomains?

merlin corey January 14, 2010 06:00PM

Re: Arbitrarily slicing $server_name into subdomains?

Igor Clark January 15, 2010 02:20PM

Re: Arbitrarily slicing $server_name into subdomains?

Tobia Conforto January 14, 2010 06:14PM

Re: Arbitrarily slicing $server_name into subdomains?

Igor Clark January 15, 2010 02:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 84
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready