Welcome! Log In Create A New Profile

Advanced

Re: Rewrite URI and pass request to the upstream server

Maxim Dounin
March 17, 2009 02:05PM
Hello!

On Tue, Mar 17, 2009 at 12:09:29PM -0500, Ruben. D. wrote:

> Hi friends, I need rewrite and old URI and pass the request to the upstream
> server, here is my current config file:
> http://pastie.org/418871
>
> If for example I have http://pe.domain.com/xx-xxx-689 I need redirect to
> http://cl.domain.com/xx-xxx-689 and let the upstream process the new
> request, with my current config I've obtained the rewrite of the URI but
> nginx return me a 404 error, therefore it is not transfering the request to
> the upstream server because the 404 error page are different between nginx
> and my application.

According to your config, [new] request to cl.domain.com/xx-xxx-689
will end up in "location ~* [a-zA-Z]+(\-)+689$", which has no proxy_pass
rules. You should either duplicate proxy_pass rules within this location, or
(better, faster, more scalable) separate pe.* and cl.* servers:

server {
listen 80;
server_name pe.domain.com;

location ~* [a-zA-Z]+(\-)+689$ {
rewrite ^ http://cl.domain.com$request_uri?;
}

...
}

server {
listen 80;
server_name www.domain.com domain.com cl.domain.com;

...
}

For identical config chunks within this servers you may want to
use include.

Maxim Dounin
Subject Author Posted

Rewrite URI and pass request to the upstream server

Ruben. D. March 17, 2009 01:35PM

Re: Rewrite URI and pass request to the upstream server

mike March 17, 2009 01:46PM

Re: Rewrite URI and pass request to the upstream server

Maxim Dounin March 17, 2009 02:09PM

Re: Rewrite URI and pass request to the upstream server

mike March 17, 2009 06:44PM

Re: Rewrite URI and pass request to the upstream server

Ruben. D. March 17, 2009 06:44PM

Re: Rewrite URI and pass request to the upstream server

Maxim Dounin March 17, 2009 02:05PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 272
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready