Load Balancing Rails on Apache 2.x

Posted by revgum on Server Fault See other posts from Server Fault or by revgum
Published on 2010-04-12T16:28:19Z Indexed on 2010/04/12 16:33 UTC
Read the original article Hit count: 302

My situation is that I need to proxy traffic to the root of my web server to port 81 for IIS, and then any traffic to a sub-directory needs to be directed to the rails app.

my-server.com/ -> needs to proxy to port 81

my-server.com/myapp -> needs to point to the rails app

This seems to be working alright for the rails application but the images, javascripts, and stylesheets are not actually working (proxied). I've tried to fiddle with the proxypass lines but it still doesn't work for me..can anyone help?

Here's my complete VirtualHost portion of the config;

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


ProxyRequests off
<Proxy balancer://myapp_cluster>
      BalancerMember http://127.0.0.1:3001
      BalancerMember http://127.0.0.1:3002
</Proxy>

<VirtualHost *:80>
    DocumentRoot "c:\ruby\apps\myapp\public"       

    <Directory /myapp >
        Options FollowSymLinks
        AllowOverride None
    </Directory>


    ProxyPass /myapp/images !
    ProxyPass /myapp/stylesheets !
    ProxyPass /myapp/javascripts ! 
    ProxyPass /myapp/ balancer://myapp_cluster/
    ProxyPassReverse /myapp/ balancer://myapp_cluster/
    ProxyPreserveHost on
    ProxyPass / http://localhost:81/

    ErrorLog "c:\ruby\apps\myapp\log\error.log"

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog "c:\ruby\apps\myapp\log\access.log" combined

</VirtualHost>

© Server Fault or respective owner

Related posts about apache2

Related posts about ruby-on-rails