Trouble with mod_proxy and mongrel_rails

Apache, Lighttpd, nginx, Cherokee
x3ro
Posts: 26
Joined: 2006-11-21 00:48

Trouble with mod_proxy and mongrel_rails

Post by x3ro » 2010-03-28 21:17

Hey there

I'm trying to set up a mod_proxy - mongrel combination, but somehow, apache/mod_proxy is unable to access mongrel locally. The following is my configuration for mod_proxy:


Code: Select all

ProxyRequests Off
ProxyPreserveHost On

<Location />
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
        Order deny,allow
        Allow from all
</Location>



Mongrel/Rails ist running just fine, because I can access it from my browser, and even with lynx on the server.

However, I get the following error when trying to use the proxy:

Code: Select all

[error] [client 127.0.0.1] Invalid Content-Length


I would appreciate any help :D

PS: Oh, and the server is running Plesk to configure vhosts, if thats important.

User avatar
daemotron
Administrator
Administrator
Posts: 2635
Joined: 2004-01-21 17:44

Re: Trouble with mod_proxy and mongrel_rails

Post by daemotron » 2010-03-28 22:54

Your ProxyPass directive is screwed. The correct statement for pass and reverse pass has to look like this:

Code: Select all

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/


In addition, you may need something like this in your vhost configuration:

Code: Select all

<Proxy *>
    Order Deny,Allow
    Allow from all
</Proxy>
“Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.” — Terry Pratchett, Thief of Time

x3ro
Posts: 26
Joined: 2006-11-21 00:48

Re: Trouble with mod_proxy and mongrel_rails

Post by x3ro » 2010-03-28 23:24

Hey there... :D

The Proxy directives were allright. When they're inside a <Location>, the location per proxy directive is not needed anymore.
I added the proxy section, and it still didn't work.
Then I tried starting the mongrel server with mongrel_rails start instead of "ruby script/server", and it magically started working...
Not sure what the difference is, though ;D

best regards,
x3ro

User avatar
daemotron
Administrator
Administrator
Posts: 2635
Joined: 2004-01-21 17:44

Re: Trouble with mod_proxy and mongrel_rails

Post by daemotron » 2010-03-28 23:38

x3ro wrote:Then I tried starting the mongrel server with mongrel_rails start instead of "ruby script/server", and it magically started working...
Not sure what the difference is, though ;D

Must be something with the HTTP headers. Perhaps it would be worth checking using nc or telnet... However, I had a mongrel server running behind an Apache proxy, and I used to start it by ruby script/server -e production. Weird...

x3ro wrote:The Proxy directives were allright. When they're inside a <Location>, the location per proxy directive is not needed anymore.

Didn't know that (and I admit I was to lazy to check it in the manual :oops: )
Btw. the <Proxy> stuff is only needed if you globally use it to deny Proxy stuff. Then you have to re-enable it on vhost level.
“Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.” — Terry Pratchett, Thief of Time