# Nginx Proxy Returns Odd Results

**URL:** <https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922>\
**Category:** NGINX\
**Created:** [May 22, 2012, 3:24am UTC](https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922 "2012-05-22T03:24:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 22, 2012, 3:24am UTC](https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922/1 "2012-05-22T03:24:36Z")

</div>

Hi,

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

The configuration I’ve put together ([http://pastebin.com/MtsvJ9Cb](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](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](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

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [May 22, 2012, 1:19pm UTC](https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922/2 "2012-05-22T13:19:27Z")

</div>

Hello!

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

> 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](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 D.

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [May 22, 2012, 7:59pm UTC](https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922/3 "2012-05-22T19:59:26Z")

</div>

On 22 May 2012 12:18, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://127.0.0.1:8080/);  
> }
> 
> location / {  
> proxy\_pass [http://127.0.0.1:8080/](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 M.  
Oxford, London, UK

> **[Jonathan Matthews :: Words Typed, Great Rates For Cash](https://www.jpluscplusm.com)**

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [May 23, 2012, 9:57am UTC](https://www.ruby-forum.com/t/nginx-proxy-returns-odd-results/219922/4 "2012-05-23T09:57:04Z")

</div>

Hello!

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

> > }
> 
> 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 [Alphabetical index of directives](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 D.
