Search code examples
ruby-on-railsapachejbosstorquebox

Configuring Apache for Rails apps under Torquebox


I'm having trouble getting Apache and Torquebox/JBoss to work together.

Versions:

  • Apache 2.2.15
  • Torquebox 2.3.0
  • Rails 2.3.18 and 3.2.13

The applications all deploy and work correctly going directly through Torquebox. I'm using a port offset of 100 with the default ports in Torquebox, so that means the application is available on myserver:8180/my-app.

Here is the configuration for my default site:

<VirtualHost *:80>
  ServerAdmin [email protected]

  DocumentRoot /var/www/html
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/httpd/error.log

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

  CustomLog /var/log/httpd/access.log combined
  ServerSignature On
</VirtualHost>

Individual apps each get their own Apache configuration file with a line like the following:

ProxyPass /my-app ajp://localhost:8109/my-app

When I try to access the applications however, I get a Forbidden (403) error message:

You don't have permission to access /my-app/ on this server.

Apache generates the following in its error.log for each failing request:

[Wed Apr 24 07:37:03 2013] [error] [client #{ip address}] client denied by server configuration: proxy:ajp://localhost:8109/my-app/

The Torquebox logs don't have a corresponding entry, so I believe the request are never making it to Torquebox.

I verified through the management console that AJP is indeed enabled for Torquebox/JBoss. I also checked file permissions on the system - the Apache user has read access to all of its configuration files and all of the app folders. The Apache configuration itself matches what is working correctly on another server as far as I can tell.

Any ideas what I am missing?


Solution

  • Proxying wasn't configured correctly. Adding this .conf file fixed the problem:

    <IfModule mod_proxy.c>
    
      ProxyRequests Off
    
      <Proxy *>
        AddDefaultCharset off
        Order allow,deny
        Allow from all
      </Proxy>
    
      ProxyVia On
    
      ProxyPreserveHost On
    
    </IfModule>