Hi Cathal, ..<br><br>You need two mongrel cluster instances, one per each rails app ok!<br><br>eg:<br><br>upstream mongrel_app_1 {<br>&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:8000">127.0.0.1:8000</a>;<br>&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:8001">127.0.0.1:8001</a>;<br>
&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:8002">127.0.0.1:8002</a>;<br>&nbsp; }<br><br>upstream mongrel_app2_2 {<br>&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;<br>&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:9001">127.0.0.1:9001</a>;<br>
&nbsp;&nbsp;&nbsp; server <a href="http://127.0.0.1:9002">127.0.0.1:9002</a>;<br>&nbsp; }<br><br>Currently I&#39;m hosting two rails app in my OpenBSD server.<br><br>Regards.<br><br><div class="gmail_quote">On Wed, Apr 2, 2008 at 5:30 PM, Cathal &lt;<a href="mailto:coriordan@tssg.org">coriordan@tssg.org</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
I&#39;m trying to configure nginx to serve multiple rails applications, each from<br>
its own path. app1 is accessible from &#39;/&#39; and app2 is accessible from &#39;/app2&#39;.<br>
<br>
In my configuration I&#39;ve defined two location&#39;s as follows:<br>
<br>
-- begin snip! --<br>
<br>
# app1<br>
location / {<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;root /u/apps/app1/current/public;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header &nbsp;X-Real-IP &nbsp;$remote_addr;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;# needed for HTTPS<br>
 &nbsp; &nbsp;proxy_set_header &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br>
 &nbsp; &nbsp;proxy_set_header Host $http_host;<br>
 &nbsp; &nbsp;proxy_redirect false;<br>
 &nbsp; &nbsp;proxy_max_temp_file_size 0;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (-f $request_filename) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
 &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp;if (-f $request_filename/index.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rewrite (.*) $1/index.html break;<br>
 &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp;if (-f $request_filename.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rewrite (.*) $1.html break;<br>
 &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp;if (!-f $request_filename) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_pass <a href="http://mongrel_app1" target="_blank">http://mongrel_app1</a>;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
 &nbsp; &nbsp; &nbsp;}<br>
}<br>
<br>
#app2<br>
location /app2 {<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;root /u/apps/app2/current/public;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header &nbsp;X-Real-IP &nbsp;$remote_addr;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;# needed for HTTPS<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_set_header Host $http_host;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_redirect false;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;proxy_max_temp_file_size 0;<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (-f $request_filename) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (-f $request_filename/index.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite (.*) $1/index.html break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (-f $request_filename.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite (.*) $1.html break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (!-f $request_filename) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_pass <a href="http://mongrel_app2" target="_blank">http://mongrel_app2</a>;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
}<br>
<br>
-- end snip! --<br>
<br>
The problem is that nginx is trying to resolve static files for /app2 along the<br>
/app2 path inside my rails application&#39;s public directory, which doesn&#39;t exist.<br>
<br>
The only way I&#39;ve been able to make the above configuration work is to create a<br>
symbolic from &#39;app2&#39; to &#39;public&#39;. Is there some way to tell nginx to ignore the<br>
location part it has already matched when dealing with a request?<br>
<br>
regards,<br>
<font color="#888888">C.<br>
<br>
<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Francisco Valladolid H.<br> -- <a href="http://bsdguy.net">http://bsdguy.net</a> - Jesus Christ follower.