Welcome! Log In Create A New Profile

Advanced

Nginx Proxy Returns Odd Results

Posted by Dan King 
Dan King
Nginx Proxy Returns Odd Results
May 22, 2012 03:30AM
Hi,

I'm trying to configure nginx as a proxy essentially imitating this
apache server (http://pastebin.com/1Tv4usjf).

The configuration I've put together (http://pastebin.com/MtsvJ9Cb)
produces odd results. For example if I use travel to:

http://127.0.0.1/ws/profiles/ff808181352a536901352a6fb6950000/requests/ff80818135fefa7e0135ff03de3a0000/images/ff80818135fefa7e0135ff03e20c0001?type=thumbnail

I'm supposed to get a thumbnail, but instead I get a full sized image.
If I bypass the nginx proxy (or use the apache proxy):

http://127.0.0.1:8080/profiles/ff808181352a536901352a6fb6950000/requests/ff80818135fefa7e0135ff03de3a0000/images/ff80818135fefa7e0135ff03e20c0001?type=thumbnail

I get the correctly sized image.

Does anyone know how can I see/log what nginx is forwarding? Does anyone
know from the config files what the problem could be?

Thanks,
-Dan

--
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Nginx Proxy Returns Odd Results
May 22, 2012 01:20PM
Hello!

On Tue, May 22, 2012 at 03:24:36AM +0200, Dan King wrote:

> Hi,
>
> I'm trying to configure nginx as a proxy essentially imitating this
> apache server (http://pastebin.com/1Tv4usjf).
>
> The configuration I've put together (http://pastebin.com/MtsvJ9Cb)
> produces odd results. For example if I use travel to:
>
> http://127.0.0.1/ws/profiles/ff808181352a536901352a6fb6950000/requests/ff80818135fefa7e0135ff03de3a0000/images/ff80818135fefa7e0135ff03e20c0001?type=thumbnail
>
> I'm supposed to get a thumbnail, but instead I get a full sized image.
> If I bypass the nginx proxy (or use the apache proxy):
>
> http://127.0.0.1:8080/profiles/ff808181352a536901352a6fb6950000/requests/ff80818135fefa7e0135ff03de3a0000/images/ff80818135fefa7e0135ff03e20c0001?type=thumbnail
>
> I get the correctly sized image.
>
> Does anyone know how can I see/log what nginx is forwarding? Does anyone
> know from the config files what the problem could be?

The problem is that you are removing request arguments in "location
~ /ws/(.*)". Use this instead:

location /ws/ {
proxy_pass http://127.0.0.1:8080/;
}

location / {
proxy_pass http://127.0.0.1:8080/;
}

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Jonathan Matthews
Re: Nginx Proxy Returns Odd Results
May 22, 2012 08:00PM
On 22 May 2012 12:18, Maxim Dounin <[email protected]> wrote:
> The problem is that you are removing request arguments in "location
> ~ /ws/(.*)".  Use this instead:
>
>    location /ws/ {
>        proxy_pass http://127.0.0.1:8080/;
>    }
>
>    location / {
>        proxy_pass http://127.0.0.1:8080/;
>    }

Are those proxy_pass trailing slashes correct?
Don't they remove the path so that the upstream sees all requests on
the root URI?

--
Jonathan Matthews
Oxford, London, UK
http://www.jpluscplusm.com/contact.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Nginx Proxy Returns Odd Results
May 23, 2012 10:00AM
Hello!

On Tue, May 22, 2012 at 06:59:01PM +0100, Jonathan Matthews wrote:

> On 22 May 2012 12:18, Maxim Dounin <[email protected]> wrote:
> > The problem is that you are removing request arguments in "location
> > ~ /ws/(.*)".  Use this instead:
> >
> >    location /ws/ {
> >        proxy_pass http://127.0.0.1:8080/;
> >    }
> >
> >    location / {
> >        proxy_pass http://127.0.0.1:8080/;
> >    }
>
> Are those proxy_pass trailing slashes correct?

Yes (you may omit one in "location /", but it doesn't really
matter).

> Don't they remove the path so that the upstream sees all requests on
> the root URI?

See http://nginx.org/r/proxy_pass:

When passing a request to the server, part of a URI matching
the location is replaced by a URI specified in the proxy_pass
directive.

Note well: this doesn't apply if you specify proxy_pass URL using
variables. In this special case the URI passed is expected to be
fully specified in proxy_pass, and this is what actually causes
original problem as it's specified without arguments.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login