Apacheで3つのサイトを実行している単一のLinuxサーバーがあります。それらをRailsApp1、RailsApp2、およびSimpleAppと呼びましょう。両方のRailsアプリケーションはMongrelクラスターを使用しています。もう1つのアプリケーションは、単一のHTMLファイルです。Apacheでは、サイトごとに異なる仮想ホストファイルを設定し、両方のRailsサイト用にmongrel_cluster.ymlファイルを設定しています(これらすべてのコードは下部にあります)。
すべてのセットアップが完了したら、Apacheでサイトを正常に有効にできます。そして、RailsサイトごとにMongrelクラスターを問題なく起動できます。実際、私のブラウザでwww.simpleapp.comとwww.railsapp1.comにアクセスすると、問題なく動作します。しかし、www.railsapp2.comは私にたくさんの問題を与えます。railsapp2のコードを表示する代わりに、サーバーはrailsapp1のHTMLを返します。Apacheでrailsapp1を無効にしてから、www.railsapp2.comにアクセスすると、サーバーはsimpleappのHTMLを返すようになりました。Apacheでrailsapp1とrailsapp2の両方を無効にした場合にのみ、サーバーはwww.railsapp2.comでの要求に正しく応答します。
なぜこれが起こっているのかについて何か考えはありますか?
SimpleAppのVHOSTファイル:
<VirtualHost *:80>
ServerName www.simpleapp.com
ServerAlias simpleapp.com
DocumentRoot /home/nudecanaltroll/public_html/simpleapp
</VirtualHost>
RailsApp1のVHOSTファイル:
<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>
RailsApp2のVHOSTファイル:
<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>
RailsApp1のmongrel_cluster.ymlファイル:
---
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
RailsApp2のmongrel_cluster.ymlファイル:
---
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