# Request path not passed to proxy when $scheme is used in proxy\_pass URI

**URL:** <https://www.ruby-forum.com/t/request-path-not-passed-to-proxy-when-scheme-is-used-in-proxy-pass-uri/227676>\
**Category:** NGINX\
**Created:** [March 24, 2013, 4:57am UTC](https://www.ruby-forum.com/t/request-path-not-passed-to-proxy-when-scheme-is-used-in-proxy-pass-uri/227676 "2013-03-24T04:57:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Hoskings](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3da27b/32.png) [@Ben\_Hoskings](https://www.ruby-forum.com/u/Ben_Hoskings)\
**Post date:** [March 24, 2013, 4:57am UTC](https://www.ruby-forum.com/t/request-path-not-passed-to-proxy-when-scheme-is-used-in-proxy-pass-uri/227676/1 "2013-03-24T04:57:12Z")

</div>

Hi all, I’ve found a strange behaviour with proxy\_pass. I’ve reduced a  
simple vhost that reproduces it:

server {  
listen 127.0.0.1:8000;  
location / {  
proxy\_pass $scheme://127.0.0.1:9000/;  
}  
}

A listener on localhost:9000 receives a request, but for ‘/’ instead of  
the  
correct path. For example, curling this URI…

> curl -I -X GET [http://localhost:8000/test-path](http://localhost:8000/test-path)

… causes a “GET /” on a local listener:

> nc -l 127.0.0.1 9000  
> GET / HTTP/1.0

If I replace $scheme with ‘http’ (i.e. “proxy\_pass  
[http://127.0.0.1:9000/](http://127.0.0.1:9000/)”),  
then it works correctly:

> curl -I -X GET [http://localhost:8000/test-path](http://localhost:8000/test-path)

> nc -l 127.0.0.1 9000  
> GET /test-path HTTP/1.0

I ran these tests on nginx-1.2.7 / OS X 10.8.3; the behaviour is the  
same  
on nginx-1.2.4 / Ubuntu 12.04 (which is where I discovered it).

Am I using $scheme incorrectly here, or could this be a bug?

Cheers,  
Ben Hoskings

---

<div class="post-metadata">

**Author:** ![Ben\_Hoskings](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3da27b/32.png) [@Ben\_Hoskings](https://www.ruby-forum.com/u/Ben_Hoskings)\
**Post date:** [March 24, 2013, 11:51am UTC](https://www.ruby-forum.com/t/request-path-not-passed-to-proxy-when-scheme-is-used-in-proxy-pass-uri/227676/2 "2013-03-24T11:51:19Z")

</div>

Ahh, I’ve found the answer in the proxy\_pass documentation.

[Module ngx\_http\_proxy\_module](http://wiki.nginx.org/HttpProxyModule#proxy_pass) – “A special case is  
using variables in the proxy\_pass statement: The requested URL is not  
used  
and you are fully responsible to construct the target URL yourself.”

Surprising, but now I know for next time 🙂

Cheers  
Ben
