Hi, List!
I`ve beed using nxingx as a local balancer for few backend servers:
http {
upstream mydomain.com {
server 192.168.8.30; # backend server
}
server {
listen 192.168.10.1:8080;
server_name cmydomain.com;
location / {
proxy_pass http://mydomain.com;
proxy_redirect off;
proxy_set_header Host $host;
}
}
}
What I need to do is for a certain url to rewrite it to an external url
but
serve the requests as a proxy instead of returing a redirect, so this is
transparent to the client:
http://mydomain.com/redirect/(.*)$ should go to
http://extranal.comain.com/$1
I saw this is possible with a simple rewrite but it returns a redirect
to the
client. Is is possible to make nginx to server the rewrite as a proxy?
On Wed, Feb 27, 2008 at 08:30:47PM +0200, Pavel Georgiev wrote:
serve the requests as a proxy instead of returing a redirect, so this is
transparent to the client:
http://mydomain.com/redirect/(.*)$ should go to http://extranal.comain.com/$1
I saw this is possible with a simple rewrite but it returns a redirect to the
client. Is is possible to make nginx to server the rewrite as a proxy?
I’m not sure that understand your problem, but this may help:
proxy_pass http://mydomain.com;
proxy_redirect http://mydomain.com/ /;
proxy_redirect http://mydomain.com/redirect/ /;
On Wed, Feb 27, 2008 at 08:30:47PM +0200, Pavel Georgiev wrote:
serve the requests as a proxy instead of returing a redirect, so this is
transparent to the client:
http://mydomain.com/redirect/(.*)$ should go to http://extranal.comain.com/$1
I saw this is possible with a simple rewrite but it returns a redirect to the
client. Is is possible to make nginx to server the rewrite as a proxy?
Or probably, you need X-Accel-Redirect:
http://wiki.codemongers.com/NginxXSendfile
On Wed, Feb 27, 2008 at 10:27:18PM +0200, Pavel Georgiev wrote:
listen 192.168.10.1:8080;
This however returns a 302 code, what I want is nginx to get the file
requested from http://some.domain.com/ and server it to the client, so that
the client doesn’t have a clue that this was taken from an external server.
In other words, I`d like to treat http://some.domain.com as a backend server,
but just for a given location.
Hope that makes sense. I don’t think X-Accel-Redirect is what I need here.
I still do not understand your problem. Probably, you need:
location / {
proxy_pass http://mydomain.com;
proxy_redirect off;
proxy_set_header Host $host;
}
location /redirect/ {
proxy_pass http://some.domain.com/;
}
On Wednesday 27 February 2008 21:08:45 Igor S. wrote:
server_name cmydomain.com;
What I need to do is for a certain url to rewrite it to an external url
Or probably, you need X-Accel-Redirect:
http://wiki.codemongers.com/NginxXSendfile
What I`m trying to do is to server some location (/redirect/ in the
example
above) to an external server. It is doable with this:
location /redirect {
rewrite ^/redirect/(.*)$ http://some.domain.com/$1
}
This however returns a 302 code, what I want is nginx to get the file
requested from http://some.domain.com/ and server it to the client, so
that
the client doesn’t have a clue that this was taken from an external
server.
In other words, I`d like to treat http://some.domain.com as a backend
server,
but just for a given location.
Hope that makes sense. I don’t think X-Accel-Redirect is what I need
here.
On Wednesday 27 February 2008 22:42:37 Igor S. wrote:
server {
rewrite as a proxy?
}
I still do not understand your problem. Probably, you need:
location / {
proxy_pass http://mydomain.com;
proxy_redirect off;
proxy_set_header Host $host;
}
location /redirect/ {
proxy_pass http://some.domain.com/;
}
Thats exactly what I needed, thanks a lot!