Forum: Rails deployment Apache/mongrelcluster config for multi (unrelated) sites on

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.
mjt (Guest)
on 2007-06-18 11:27
(Received via mailing list)
Hi all,

I am attempting to setup two disparate sites on a single in-house
host.
I have the first one up and going OK and dont want to bend it while
bringing up a second.

Is this apache / mongrel config appropriate ? Currently the Proxy line
for the mongrel stuff is
<Proxy balancer://mongrel_cluster>

I am assuming that I can change the name(s) to this
<Proxy balancer://app_one_cluster>
<Proxy balancer://app_two_cluster>

cheers
mjt

--------8<-------------
#
# Virtual Site ONE  mongrel ports at 5000+
#
<VirtualHost *:80>
  ServerName app_one.com
  DocumentRoot /var/rails/app_one/current/public
  <Directory "/var/rails/app_one/current/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  # Configure mongrel_cluster
  <Proxy balancer://app_one_cluster>
    BalancerMember http://127.0.0.1:5000
    BalancerMember http://127.0.0.1:5001
    BalancerMember http://127.0.0.1:5002
  </Proxy>
  RewriteEngine On
  # If there is a maintenence.html file in your
  # public dir all requests will get rerouted to
  # this file.
  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /maintenance.html [L]
  # Rewrite index to check for static index.html
  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 mongrel cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://app_one_cluster%{REQUEST_URI}
[P,QSA,L]
  # Deflate
  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
  ErrorLog logs/app_one_error_log
  CustomLog logs/your_access_log combined
</VirtualHost>

#
# Virtual Site TWO  mongrel ports at 5020+
#
<VirtualHost *:80>
  ServerName app_two.com
  DocumentRoot /var/rails/app_two/current/public
  <Directory "/var/rails/app_two/current/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
  # Configure mongrel_cluster
  <Proxy balancer://app_two_cluster>
    BalancerMember http://127.0.0.1:5020
    BalancerMember http://127.0.0.1:5021
    BalancerMember http://127.0.0.1:5022
  </Proxy>
  RewriteEngine On
  # If there is a maintenence.html file in your
  # public dir all requests will get rerouted to
  # this file.
  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /maintenance.html [L]
  # Rewrite index to check for static index.html
  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 mongrel cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://app_two_cluster%{REQUEST_URI}
[P,QSA,L]
  # Deflate
  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
  ErrorLog logs/app_two_error_log
  CustomLog logs/your_access_log combined
</VirtualHost>
Luca M. (Guest)
on 2007-06-18 12:12
(Received via mailing list)
It looks good to me which is mostly the same as this one I'm using
(generated by the railsmachine gem):

<VirtualHost *:80>
  ServerName prototype.mysite.info
  ServerAlias www.prototype.mysite.info
  DocumentRoot /var/www/apps/mysite/current/public

  <Directory /var/www/apps/mysite/current/public>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>

  # Configure mongrel_cluster
  <Proxy balancer://mysite_cluster>
    BalancerMember http://127.0.0.1:8100
    BalancerMember http://127.0.0.1:8101
  </Proxy>

  RewriteEngine On

  # Prevent access to .svn directories
  RewriteRule ^(.*/)?\.svn/ - [F,L]
  ErrorDocument 403 "Access Forbidden"

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # Rewrite index to check for static
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://mysite_cluster%{REQUEST_URI} [P,QSA,L]

  # Deflate
  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

  ErrorLog logs/prototype.mysite.info-error_log
  CustomLog logs/prototype.mysite.info-access_log combined
</VirtualHost>

bye
Luca

2007/6/18, mjt <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.