
몇 가지 사소한 구성 변경을 제외하고 서로 복제되는 두 개의 서버가 있습니다. Monitoring.*.com 하위 도메인을 방문하려고 할 때 예상치 못한 동작이 발생합니다.
각 서버에서 실행하면 ./apache2ctl -S
다음이 제공됩니다.
스테이징 서버
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server 010.staging.com (/etc/apache2/sites-enabled/010:2)
port 443 namevhost 010.staging.com (/etc/apache2/sites-enabled/010:2)
port 443 namevhost 011.staging.com (/etc/apache2/sites-enabled/011:2)
port 443 namevhost 013.staging.com (/etc/apache2/sites-enabled/013:2)
*:80 is a NameVirtualHost
default server www.production.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost www.production.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost monitoring.staging.com (/etc/apache2/sites-enabled/monitoring:1)
Syntax OK
프로덕션 서버
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server de.production.com (/etc/apache2/sites-enabled/de:2)
port 443 namevhost de.production.com (/etc/apache2/sites-enabled/de:2)
port 443 namevhost uk.production.com (/etc/apache2/sites-enabled/uk:2)
port 443 namevhost us.production.com (/etc/apache2/sites-enabled/us:2)
port 443 namevhost www.production.com (/etc/apache2/sites-enabled/production:2)
*:80 is a NameVirtualHost
default server www.production.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost www.production.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost monitoring.production.com (/etc/apache2/sites-enabled/monitoring:1)
Syntax OK
000-default의 구성은 두 서버 모두 다음과 같습니다.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.production.com
DocumentRoot /home/user/apache/
RewriteEngine on
RewriteLog /var/log/apache2/log
RewriteLogLevel 1
RewriteCond %{REQUEST_URI}/ !^(/server-status).*$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>
내가 겪고 있는 문제는 내가 방문할 때 기본 보안 포트 서버용 앱 http://monitoring.staging.com
으로 리디렉션되어 제공된다는 것입니다.http**s**.monitoring.staging.com
010.staging.com
프로덕션 서버가 예상대로 작동하고 내 애플리케이션 모니터링 도구를 제공하고 있습니다.
제가 말했듯이 이 두 서버는 아주 사소한 구성 변경만으로 마스터 이미지의 복제본으로 시작되었습니다. 필요한 경우 구체적인 변경 사항을 설명할 수 있습니다.
내가 왜 이런 행동을 하는지 추측할 수 있는 사람이 있나요?
감사합니다
업데이트:
모니터링을 위한 Vhost 구성은 다음과 같습니다.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName monitoring.staging.com
DocumentRoot /var/www/munin
<Directory /var/www/munin>
Options FollowSymLinks
AllowOverride None
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel notice
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
ServerSignature On
</VirtualHost>
그리고 실제로 제공되는 앱의 경우:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName 010.staging.com
RewriteLog /var/log/apache2/ssl.log
RewriteRule ^/$ /010/home.htm [R=301,L]
RewriteRule ^/(?!010/|static/|mgt).*$ /010/home.htm [R=301,L]
SSLCertificateKeyFile /etc/apache2/ssl/010/apache.key
SSLCertificateFile /etc/apache2/ssl/010/apache.crt
SSLCACertificateFile /etc/apache2/ssl/010/apache-ca.crt
</VirtualHost>
</IfModule>
답변1
000-default
준비 구성을 다음과 같이 변경하여 이 문제를 해결했습니다 .
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName staging.com
DocumentRoot /home/user/apache/
RewriteEngine on
RewriteLog /var/log/apache2/log
RewriteLogLevel 1
RewriteCond %{REQUEST_URI}/ !^(/server-status).*$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>
ServerName이 www.production.com에서 stage.com으로 변경되었습니다.
모르겠습니다왜이로 인해 문제가 해결되었으므로 해당 동작과 Apache가 수행하는 작업을 설명할 수 있는 사람에게 정답 표시를 제공하게 되어 기쁩니다.