Forum: Ruby on Rails Rails + Apache2 + Balancer Manager - PHP doesn't work

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andi G. (Guest)
on 2008-10-11 21:16
Hi

I have a Debian Server and I managed that Ruby works with Apache2 and
the Balancer Manager that listen to the Mongrel server.

The Problem is that PHP files don't work anymore.

How do I have to configurate the Balance Manager that PHP is working
again like without the Balance Manager?


Greetings Andi
Freddy A. (Guest)
on 2008-10-11 23:46
(Received via mailing list)
You are going to have a virtualhost that does not forward all request
to your mongrel... If the request is sent to a mongrel you will ne be
able to render the php file...

SO here are some basics:

<virtualhost>
DirectoryIndex index.php
DocumentRoot "/disk/phpcode"

alias /railscode/javascripts /disk/railscode/public/javascripts
alias /railscode/images /disk/railscode/public/images


<Directory "/disk/phpcode">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

<Directory "/disk/railscode/public">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>


<Location "/railscode">
  proxyPass balancer://mongrel/railscode
</Location>


<virtualhost>
Andi G. (Guest)
on 2008-10-12 13:08
Hi Freddy

I am operating under ISPConfig, this is my Vhost File:


----------------------------------------------------------------------


NameVirtualHost xx.xx.xx.xx:80
<VirtualHost xx.xx.xx.xx:80>
  ServerName localhost
  ServerAdmin root@localhost
  DocumentRoot /var/www/sharedip
  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
  </IfModule>
</VirtualHost>

<Proxy balancer://aekschencluster>
# Mitglieder des Clusters
BalancerMember http://xx.xx.xx.xx:82
</Proxy>

ExtendedStatus On

<VirtualHost xx.xx.xx.xx:80>

ProxyRequests Off
#ProxyPass /balancer-manager !
#ProxyPass /server-status !
ProxyPass / balancer://aekschencluster/
ProxyPassReverse / balancer://aekschencluster/

ServerName www.domain.tdl:80
ServerAdmin removed_email_address@domain.invalid
DocumentRoot /var/www/web1/web
ServerAlias domain.tdl
DirectoryIndex index.html index.htm index.php index.php5 index.php4
index.php3 index.shtml index.cgi index.pl index.jsp Default.htm
default.htm
Alias  /cgi-bin/ /var/www/web1/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/web1/log/error.log
AddType application/x-httpd-php .php .php3 .php4 .php5
php_admin_flag safe_mode Off
<IfModule mod_ruby.c>
  <Directory /var/www/web1/web>
    #Options +ExecCGI
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  RubyRequire apache/ruby-run
  #RubySafeLevel 0
  <Files *.rb>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
  <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
</IfModule>
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Alias /error/ "/var/www/web1/web/error/"
ErrorDocument 400 /error/invalidSyntax.html
ErrorDocument 401 /error/authorizationRequired.html
ErrorDocument 403 /error/forbidden.html
ErrorDocument 404 /error/fileNotFound.html
ErrorDocument 405 /error/methodNotAllowed.html
ErrorDocument 500 /error/internalServerError.html
ErrorDocument 503 /error/overloaded.html
AliasMatch ^/~([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
  RewriteRule .* - [F]
</IfModule>
</VirtualHost>

----------------------------------------------------------------------

The ruby projekt is under var/www/web1/
The ruby public is under a symlink var/www/web1/public to
var/www/web1/web/
The normal apache is under var/www/web1/web/


Is the error coming from the missing Directory entry?

Greetings Andi
Andi G. (Guest)
on 2008-10-12 21:36
aaah okay know I know:

-------------------------------------------------------------
<VirtualHost xx.xx.xx.xx:80>

<IfModule mod_proxy_balancer.c>

<Proxy balancer://aekschencluster>
BalancerMember http://xx.xx.xx.xx:82
</Proxy>


<Location /de/>
ProxyPass balancer://aekschencluster/ stickysession=JSESSIONID
#ProxyPassReverse balancer://aekschencluster/de/
</Location>

</IfModule>

-------------------------------------------------------------

With the location tag you define a URL when the proxy should be active.

But my problem is know the link routing from rails because the URL is
now http://www.domain.tdl/de/rubyapplication

But in my Rails application the links route all to the root
http://www.domain.tdl/

What could I do?

Greetings Andi
Andi G. (Guest)
on 2008-10-12 23:20
okay I found an other solution.

I did it the other way around:

ProxyPass /phpBB3 !
ProxyPass / balancer://aekschencluster/ stickysession=JSESSIONID


I set the phpBB3 Forum as an exception.

greetings
Freddy A. (Guest)
on 2008-10-13 04:06
(Received via mailing list)
Depends on the rails backed but if you are using mongrel or thin you
can setup a prefix for the app...

setup a prefix of /app and then in the balancer you use ProxyPass /
balancer://cluster/app
This topic is locked and can not be replied to.