<div dir="ltr">Here is some code maybe will help you...:)<br><br> if ($host ~* (.+)\.(.*)\.91\.com(.*))<br> {<br> set $dir_a $1;<br> set $dir_b $2;<br><br> rewrite ^(.*)$ /activity/$dir_b/$dir_a$1 last;<br>
}<br><br><br> location /<br> {<br> proxy_pass <a href="http://127.0.0.1:8080">http://127.0.0.1:8080</a>;<br> }<br><br><br><div class="gmail_quote">On Wed, Jul 30, 2008 at 9:34 AM, W. Andrew Loe III <span dir="ltr"><<a href="mailto:andrew@andrewloe.com">andrew@andrewloe.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I have a relatively complex setup but I believe nginx has the ability<br>
to do everything I am looking for. I want to proxy requests for files<br>
to different servers using x-accel-redirect.<br>
<br>
A request cycle might look like this:<br>
client => interwebs => nginx1 => mongrel (which does some lifting and<br>
then replies back with x-accel-redirect and a url like<br>
/under_the_covers/<a href="http://10.10.1.2/file.jpg" target="_blank">10.10.1.2/file.jpg</a>) => nginx1 (at this point the<br>
location directive catch the /under_the_covers and do what I want) =><br>
some-other-webserver (<a href="http://10.10.1.2" target="_blank">10.10.1.2</a>) => nginx1 => interwebs => client.<br>
<br>
In psuedo code I want something like:<br>
<br>
location /under_the_covers/(.*) {<br>
internal;<br>
proxy_pass http://$1;<br>
}<br>
<br>
I have tried a few methods but I cannot seem to get it correct.<br>
<br>
location /under_the_covers/ {<br>
rewrite ^/under_the_covers/(.*)/(.*)$ $2;<br>
proxy_pass http://$1;<br>
}<br>
<br>
I have no trouble if I manually set the host in the proxy pass. So the<br>
mongrel replies with x-accel-redirect = /under_the_covers/file.jpg and<br>
location looks like so:<br>
<br>
location /under_the_covers/(.*) {<br>
proxy_pass <a href="http://10.10.1.2" target="_blank">http://10.10.1.2</a>;<br>
}<br>
<br>
<a href="http://article.gmane.org/gmane.comp.web.nginx.english/6206/match=proxy_pass" target="_blank">http://article.gmane.org/gmane.comp.web.nginx.english/6206/match=proxy_pass</a><br>
<br>
There is discussion there on using proxy_pass with variables but I<br>
cannot either construct the uri correctly or I can't get the hostname<br>
set from a regular expression.<br>
<br>
Thank you for your time,<br>
<font color="#888888">-- Andrew<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>The time you enjoy weasting is not weasted time!<br>
</div>