location style hostname matching?

Igor Sysoev is at rambler-co.ru
Sun Feb 10 10:50:20 MSK 2008


On Sat, Feb 09, 2008 at 11:32:02PM -0800, Allen Parker wrote:

> If my configuration (sample) looks like this:
> 
> http {
> 	server {
> 	server_name	_*;
> 	root		/path/to/htdocs/$host;
> }}
> 
> is there a way to match 'location' or perhaps another type of keyword to 
> hostname for one particular vhost ie:
> 
> location a.host.net {
> 	rewrite /blog(.+)$ /wordpress$1;
> }
> location b.host.net {
> 	root	/other/filepath/to/$host;
> }
> 
> What I'm looking for is something similar to lighttpd's $HTTP['host'].

http {

     root		/path/to/htdocs/$host;

     server {
        server_name  _;  # default server
     }

     server {
        server_name  a.host.net;
  	rewrite /blog(.+)$ /wordpress$1;
     }

     server {
        server_name  b.host.net;
  	root	/other/filepath/to/b.host.net;
     }
}


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list