------------------------------
Message: 3
Date: Thu, 22 Mar 2012 00:33:02 +0400
From: "Valentin V. Bartenev" <n...@vbart.ru>
To: nginx@nginx.org
Subject: Re: Rewrite Subdomains to Paths
Message-ID: <2012032200...@vbart.ru>
Content-Type: Text/Plain; charset="iso-8859-6"
On Thursday 22 March 2012 00:15:00 Kurtis Mullins wrote:
> Hey,
>
> Is it possible to rewrite subdomains to paths? I want to do something like
> this:
>
> x.example.com/foo/bar/ -> www.example.com/x/foo/bar/
>
server {
server_name ~^(?P<subdomain>.+)\.example\.com$;
location / {
return 301 http://www.example.com/$subdomain$request_uri;
}
}
wbr, Valentin V. Bartenev
Hi there,
> Anyways, this would definitely work for redirects. Is it possible to do it
> in a way that is transparent to the end-user and my WSGI Application
> server?
That's (mostly) up to your application server.
> Basically, when the user accesses
> username.example.com/foo/bar/then my WSGI Application would just see "
> example.com/username/foo/bar/".
On the nginx side, you "just" adjust the uwsgi_param values that you send.
(Assuming that's how nginx access the application.)
But before you do that: try accessing the WSGI Application using the
example.com/username/foo/bar/ style urls. Look in the returned content. Do
you see the string "username" anywhere? Do you see any linked content
with a url that starts "/" or with multiple "../"? Do you see any linked
content with a url that includes "example.com"?
If you do, consider how they will look to a client which thinks that
its initial request was to username.example.com/foo/bar.
You can get nginx to mangle http headers. You shouldn't get nginx to
mangle the http body.
It can work. But it is worth testing your particular setup to make sure
that it works for you.
f
--
Francis Daly fra...@daoine.org
_______________________________________________
nginx mailing list
ng...@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx