403 (Forbidden) with Apache on Mongrel Cluster

Hi,

I’ve configured a rails application on my VPS to run on two
mongrels. When I run curl on localhost, the starting page comes up
fine. That is, mongrel is serving the app perfectly.

The problem arises when trying to access the app on my ip through
apache. I
get a 403 error. Just to test things out, I’ve set generous
permissions on the entire rails directory structure still to no avail.

I’ve also set up a non-rails virtual host, and everything works fine
there. So I doubt that it’s a vhost problem.

What could be the problem here? Any insights would be awesome; to me,
it’s been a real gordian knot.

Thanks,

Kyle

knb wrote:

I’ve also set up a non-rails virtual host, and everything works fine
there. So I doubt that it’s a vhost problem.

What could be the problem here? Any insights would be awesome; to me,
it’s been a real gordian knot.

Hard to say without seeing your Apache config and Mongrel config/command
line.


Michael W.

On 3 Oct 2007, at 15:09, knb wrote:

Thanks, Michael.

Here’s the relevant config info.

Well either your mail client has munged your config or it’s rather
malformed. You’re not closing the VirtualHost ‘tags’, sections are
duplicated, you’ve nested the balancer declarations inside the
Virtual host stuff etc…

In particular you declare your cluster as mongrel_cluster, but in
your rewrite rule you’ve put your_app_cluster

Fred

Thanks, Michael.

Here’s the relevant config info.

<VirtualHost *:80>
ServerName lessonkit.com
DocumentRoot /home/kyle/public_html/lessonkit.com/current/public

<Directory “/home/kyle/public_html/lessonkit.com/current/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

RewriteEngine On
<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:5000
BalancerMember http://127.0.0.1:5001

<VirtualHost *:80>
ServerName lessonkit.com
DocumentRoot /home/kyle/public_html/lessonkit.com/current/public

<Directory “/home/kyle/public_html/lessonkit.com/current/public”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

RewriteEngine On
<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:5000
BalancerMember http://127.0.0.1:5001

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
RewriteRule ^/$ /index.html [QSA]

Rewrite to check for Rails cached pages with .html extentions

RewriteRule ^([^.]+)$ $1.html [QSA]

All dynamic requests get sent to the cluster

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://your_app_cluster%{REQUEST_URI}
[P,QSA,L]

Deflate for clients that support it.

AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Error and access logs.

ErrorLog logs/your_app_error_log
CustomLog logs/your_access_log combined

Here’s my mongrel config:

cwd: /home/kyle/public_html/lessonkit.com/current
log_file: /home/kyle/public_html/lessonkit.com/current/log/mongrel.log
port: “5000”
environment: production
address: 127.0.0.1
pid_file: /home/kyle/public_html/lessonkit.com/current/tmp/pids/
mongrel.pid
servers: 2