Multiple rails apps on different ports w/ Apache/Passenger

Hi there. This thread is the closest to what I’m trying to do.

http://www.ruby-forum.com/topic/132408#new

I have three rails apps on one machine with Apache2/Passenger/REE. I
want them available at www.example.com/app1 and so on. I’m trying to
avoid www.example.com:8080 , 8081, 8082, etc. for various reasons. I’d
like to avoid going the Apache2 mod_rewrite route. Also, I plan to take
advantage of additional Nginx features after I get this working. For
example, I’d like Nginx to serve the static.

I’ve got some experience with Nginx – but not a lot. I would really
appreciate a few pointers – it’s been challenging.

Thanks! P

I am not sure exactly what you trying to do. But you can have NginX +
Passenger do this directly. And i am sure you can do it directly with
Apache + Passenger also.

http://modrails.org/documentation/Users%20guide%20Nginx.html#deploying_rails_to_sub_uri

Rob S. wrote:

I am not sure exactly what you trying to do. But you can have NginX +
Passenger do this directly. And i am sure you can do it directly with
Apache + Passenger also.

http://modrails.org/documentation/Users%20guide%20Nginx.html#deploying_rails_to_sub_uri

I’m putting three apps onto a linux box sitting in my bedroom. I’m
putting them online through dynamic DNS [dyndns]. I would prefer to
only open one port: 80. I could simply open more ports and tack :8080
and such onto the end of the url. That’s ugly.

Yes, I could use Apache mod_rewrite. I ** don’t like ** apache rewrite.
Yes, I’m sure that I could do this with Nginx/passenger alone. The one
time I tried Nginx/passenger together, it didn’t benchmark well. That
may have been my own ignorance of Nginx. And truly, performance may not
be much of an issue.

Finally, I really like this combination with Nginx serving the static
files and Apache/passenger serving the rails requests. Shopify runs
like this. I created my own demo setup with Nginx serving static files
and proxying to a cluster of Apache2/passenger servers running on
multiple machines. It’s awesome!

May be I’m over-thinking it here. It seems to me that this similar setup
would work well in this case. It’s just that I can’t get the Nginx
configuration file right. From Nginx’s perspective, it shouldn’t care
that it’s passing rails to passenger. Sadly, I’m also ignorant of
Mongrel. I think that’s why I’m struggling to make this work from that
example.

Thanks for the help.

–Paul

On Sep 8, 2009, at 7:26 PM, Paul Hamann wrote:

I’m putting three apps onto a linux box sitting in my bedroom. I’m
putting them online through dynamic DNS [dyndns]. I would prefer to
only open one port: 80. I could simply open more ports and tack :8080
and such onto the end of the url. That’s ugly.
The suburl document that i linked to is Passenger’s official support
for multiple rails application running on 1 apache/nginx instance. The
apache specific portion can be found under the apache documentation.
Then you could just have NginX or apache listening on port 80 and
handling all the requests without having to proxy to multiple
instances of apache.

Yes, I could use Apache mod_rewrite. I ** don’t like ** apache
rewrite.
Yes, I’m sure that I could do this with Nginx/passenger alone. The
one
time I tried Nginx/passenger together, it didn’t benchmark well. That
may have been my own ignorance of Nginx. And truly, performance may
not
be much of an issue.
I am pretty sure you shouldn’t see any slower performance with NginX +
Passenger then having NginX / Apache + passenger. I mean you taking 1
less software out of the stack. If you having performance issues then
might wish to post your config or it could be a bug or issue with the
passenger NginX module.

May be I’m over-thinking it here. It seems to me that this similar
setup
would work well in this case. It’s just that I can’t get the Nginx
configuration file right. From Nginx’s perspective, it shouldn’t care
that it’s passing rails to passenger. Sadly, I’m also ignorant of
Mongrel. I think that’s why I’m struggling to make this work from
that
example.
I think for the setup you would be needing a combination of
location /app1 {
alias /path/to/app1/public;
try_files $uri @apache;
}

location /app2 {
alias /path/to/app2/public;
try_files $uri @apache;
}

location @apache {
proxy_pass http://localhost:8080;
}

This config probably won’t work outta the box. I wrote it pure outta
memory and that is shoddy at best!. But i think it might give you a
general idea. Also not sure if root or alias would work best here.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs