<div dir="ltr">Here is some code maybe will help you...:)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($host ~* (.+)\.(.*)\.91\.com(.*))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set $dir_a $1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set $dir_b $2;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rewrite ^(.*)$ /activity/$dir_b/$dir_a$1 last;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location /<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxy_pass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://127.0.0.1:8080">http://127.0.0.1:8080</a>;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br><div class="gmail_quote">On Wed, Jul 30, 2008 at 9:34 AM, W. Andrew Loe III <span dir="ltr">&lt;<a href="mailto:andrew@andrewloe.com">andrew@andrewloe.com</a>&gt;</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 =&gt; interwebs =&gt; nginx1 =&gt; 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>) =&gt; nginx1 (at this point the<br>
location directive catch the /under_the_covers and do what I want) =&gt;<br>
some-other-webserver (<a href="http://10.10.1.2" target="_blank">10.10.1.2</a>) =&gt; nginx1 =&gt; interwebs =&gt; client.<br>
<br>
In psuedo code I want something like:<br>
<br>
location /under_the_covers/(.*) {<br>
 &nbsp;internal;<br>
 &nbsp;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>
 &nbsp;rewrite ^/under_the_covers/(.*)/(.*)$ $2;<br>
 &nbsp;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>
 &nbsp; 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&#39;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>