Igor,
I’ve searched the mailing lists and read the docs and played around with
the
server but can’t quite come up with what I’m trying to do.
I am trying to configure
.staging.example.com proxy to backend staging.example.com/
so for example:
hi_mom.staging.example.com in the backend goes to
staging.example.com/hi_mom/…
but the clients do not see the rewrite, eg they stay on
hi_mom.staging.example.com
Is there a way to do this with Nginx?
The only thing I’ve found that is close is :
http://pastie.textmate.org/private/7oox7dwjlejheocxufg
Thanks,
~Wayne
server {
no server_name statement
set $subdomain “index.html”;
if ($http_host ~ “^(.+?).”) {
set $subdomain $1;
}
rewrite ^/(.*) http://staging.example.com/$subdomain/$1 last;
}
probably works. Note that “_” isn’t a valid domain character.
Er, sorry that won’t work. It’s probably remedied, however, if you
shove the last http://* string into a proxy_pass statement and make
sure you use a newer version of 0.6.x so that you can use variables in
the proxy_pass.
eg.
proxy_pass http://staging.example.com/$subdomain;
On Dec 19, 2007 3:59 PM, Eden Li [email protected] wrote:
Thanks for the reply Eden!
This alas does not do the trick.
changing last to permanent semi works except that it rewrites the users
url
which is not the goal.
So I need something that is transparent to the user. Any more ideas?
Thanks again!
~Wayne
On Dec 19, 2007 4:32 PM, Eden Li [email protected] wrote:
You need to use proxy_pass to have nginx funnel the content from
staging.example.com in order for it to appear to be coming from
subdomain.staging.example.com.
proxy_pass variable support was added in 0.6.18
I’m willing to add 0.6.X to gain this feature.
What would it look like then?
probably something like:
server {
no server_name statement
set $subdomain “default”;
if ($http_host ~ “^(.+?).”) {
set $subdomain $1;
}
proxy_pass http://staging.example.com/${subdomain}$request_uri;
}
You might need to add a slash here between subdomain and request_uri.
You need to use proxy_pass to have nginx funnel the content from
staging.example.com in order for it to appear to be coming from
subdomain.staging.example.com.
proxy_pass variable support was added in 0.6.18
On Dec 19, 2007 10:39 PM, Eden Li [email protected] wrote:
proxy_pass http://staging.example.com/${subdomain}$request_urihttp://staging.example.com/${subdomain}$request_uri
;
}
You might need to add a slash here between subdomain and request_uri.
Eden I could kiss you right now 
On Wed, Dec 19, 2007 at 03:41:00PM -0500, Wayne E. Seguin wrote:
staging.example.com/hi_mom/…
but the clients do not see the rewrite, eg they stay on
hi_mom.staging.example.com
Is there a way to do this with Nginx?
The only thing I’ve found that is close is :
http://pastie.textmate.org/private/7oox7dwjlejheocxufg
server {
server_name .staging.example.com;
if ($http_host ~ ^(.+)\staging\.example\.com) {
set $name $1;
rewrite ^(.+)$ /$name$1;
}
location / {
proxy_pass http://staging.example.com:8000;
}
}