<div dir="ltr">Ahh, I've found the answer in the proxy_pass documentation.<div><br></div><div><a href="http://wiki.nginx.org/HttpProxyModule#proxy_pass">http://wiki.nginx.org/HttpProxyModule#proxy_pass</a> -- "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."</div>
<div><br></div><div style>Surprising, but now I know for next time :)</div><div style><br></div><div style>Cheers</div><div style>Ben</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 24 March 2013 14:56, Ben Hoskings <span dir="ltr"><<a href="mailto:ben@hoskings.net" target="_blank">ben@hoskings.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><span style="font-family:arial,sans-serif;line-height:normal">Hi all, I've found a strange behaviour with proxy_pass. I've reduced a simple vhost that reproduces it:</span><div style="font-family:arial,sans-serif;line-height:normal">
<br></div><div style="font-family:arial,sans-serif;line-height:normal"><div>server {</div><div> listen <a href="http://127.0.0.1:8000/" target="_blank">127.0.0.1:8000</a>;</div><div> location / {<br></div><div> proxy_pass $scheme://<a href="http://127.0.0.1:9000/" target="_blank">127.0.0.1:9000/</a>;</div>
<div> }</div><div>}</div></div><div style="font-family:arial,sans-serif;line-height:normal"><div><br></div><div>A listener on localhost:9000 receives a request, but for '/' instead of the correct path. For example, curling this URI...</div>
<div>> curl -I -X GET <a href="http://localhost:8000/test-path" target="_blank">http://localhost:8000/test-path</a><br></div><div><br></div><div>... causes a "GET /" on a local listener:<br></div><div><div>> nc -l 127.0.0.1 9000</div>
<div>GET / HTTP/1.0</div><div><br></div><div>If I replace $scheme with 'http' (i.e. "proxy_pass <a href="http://127.0.0.1:9000/" target="_blank">http://127.0.0.1:9000/</a>"), then it works correctly:</div>
<div>> curl -I -X GET <a href="http://localhost:8000/test-path" target="_blank">http://localhost:8000/test-path</a><br></div><div><br></div><div><div>> nc -l 127.0.0.1 9000</div><div>GET /test-path HTTP/1.0</div></div>
</div><div><br></div><div>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).<br></div><div><br></div><div>Am I using $scheme incorrectly here, or could this be a bug?</div>
<div><br></div><div>Cheers,<br></div><div>Ben Hoskings</div></div></div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Cheers<div>Ben</div><div><br></div>
</div>