J'ai un seul serveur Linux qui exécute 3 sites sur Apache. Appelons-les RailsApp1, RailsApp2 et SimpleApp. Les deux applications Rails utilisent des clusters Mongrel. L'autre application est juste un seul fichier HTML. J'ai différents fichiers d'hôtes virtuels configurés dans Apache pour chaque site, ainsi que des fichiers mongrel_cluster.yml pour les deux sites Rails (le code pour tout ceci est en bas).Configuration d'hôtes virtuels pour les applications Rails sur Apache et Mongrel
Avec toute la configuration, je peux très bien activer les sites dans Apache. Et je peux très bien démarrer les clusters Mongrel pour chaque site Rails. Et, en fait, en visitant www.simpleapp.com et www.railsapp1.com dans mon navigateur fonctionne très bien. Cependant, www.railsapp2.com me donne beaucoup de problèmes. Au lieu d'afficher le code pour railsapp2, le serveur renvoie le code HTML pour railsapp1. Si je désactive railsapp1 dans Apache, puis aller à www.railsapp2.com, le serveur retourne maintenant le HTML pour simpleapp. Seulement si je désactive à la fois les railsapp1 et les railsapp2 dans Apache, le serveur répondra correctement à une demande sur www.railsapp2.com.
Avez-vous des idées sur la raison pour laquelle cela pourrait se produire?
Fichier vhost de SimpleApp:
<VirtualHost *:80>
ServerName www.simpleapp.com
ServerAlias simpleapp.com
DocumentRoot /home/nudecanaltroll/public_html/simpleapp
</VirtualHost>
Fichier vhost de RailsApp1:
<VirtualHost *:80>
ServerName railsapp1.com
DocumentRoot /home/nudecanaltroll/public_html/railsapp1/public
RewriteEngine On
<Proxy balancer://mongrel1>
BalancerMember http://127.0.0.1:5000
BalancerMember http://127.0.0.1:5001
BalancerMember http://127.0.0.1:5002
</Proxy>
# Timeout in 30 seconds
ProxyTimeout 30
# Make sure people go to www.railsapp1.com, not railsapp1.com
RewriteCond %{HTTP_HOST} ^railsapp1\.com$ [NC]
RewriteRule ^(.*)$ http://www.railsapp1.com$1 [R=301,NE,L]
# Redirect all non-static requests to thin
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/mongrel1(.*)$ balancer://mongrel1%{REQUEST_URI} [P,QSA,L]
# Proxy Stuff
ProxyPass/balancer://mongrel1/
ProxyPassReverse/balancer://mongrel1/
ProxyPreserveHost on
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Custom log file locations
ErrorLog /home/nudecanaltroll/public_html/railsapp1/log/error.log
CustomLog /home/nudecanaltroll/public_html/railsapp1/log/access.log combined
</VirtualHost>
Fichier vhost de RailsApp2:
<VirtualHost *:80>
ServerName railsapp2.com
DocumentRoot /home/nudecanaltroll/public_html/railsapp2/public
RewriteEngine On
<Proxy balancer://mongrel2>
BalancerMember http://127.0.0.1:6000
BalancerMember http://127.0.0.1:6001
BalancerMember http://127.0.0.1:6002
</Proxy>
# Timeout in 30 seconds
ProxyTimeout 30
# Make sure people go to www.railsapp2.com, not railsapp2.com
RewriteCond %{HTTP_HOST} ^railsapp2\.com$ [NC]
RewriteRule ^(.*)$ http://www.railsapp2.com$1 [R=301,NE,L]
# Redirect all non-static requests to thin
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/mongrel2(.*)$ balancer://mongrel2%{REQUEST_URI} [P,QSA,L]
# Proxy Stuff
ProxyPass/balancer://mongrel2/
ProxyPassReverse/balancer://mongrel2/
ProxyPreserveHost on
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Custom log file locations
ErrorLog /home/nudecanaltroll/public_html/railsapp2/log/error.log
CustomLog /home/nudecanaltroll/public_html/railsapp2/log/access.log combined
</VirtualHost>
le fichier mongrel_cluster.yml de RailsApp1:
---
address: 127.0.0.1
log_file: log/mongrel.log
port: 5000
cwd: /home/nudecanaltroll/public_html/railsapp1
environment: production
pid_file: /home/nudecanaltroll/public_html/railsapp1/tmp/pids/mongrel.pid
servers: 3
fichier mongrel_cluster.yml de RailsApp2:
---
address: 127.0.0.1
log_file: log/mongrel.log
port: 6000
cwd: /home/nudecanaltroll/public_html/railsapp2
environment: production
pid_file: /home/nudecanaltroll/public_html/railsapp2/tmp/pids/mongrel.pid
servers: 3