我正在迁移一个网络服务器,并且遇到了 Apache mod_substitute 的问题。在旧服务器上一切正常,对 HTTP 和 HTTPS 请求都进行了正确的替换。
在新服务器上,仅对 HTTP 请求进行替换。新服务器具有与旧服务器相同的文件结构和相同的操作系统 (CentOS 5.6)。服务器之间的 Apache 配置存在一些差异,但我无法弄清楚可能导致问题的原因。我试过 LogLevel 调试但没有用。
一些 conf 文件以查看差异:(删除注释以节省空间)
旧服务器(有效)
conf.d/ssl.conf
LoadModule ssl_module modules/mod_ssl.so
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
<IfDefine SSL>
Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache dbm:/etc/httpd/logs/ssl_scache
SSLSessionCacheTimeout 300
SSLMutex file:/etc/httpd/logs/ssl_mutex
</IfDefine>
新服务器(mod_substitute 不对 https:// 请求执行任何操作)
conf.d/ssl.conf
LoadModule ssl_module modules/mod_ssl.so
Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
相关的 VHosts 部分(在两个服务器上相同),https:// 页面页面确实显示(并且证书信息是正确的),只有 mod_substitute 无法将 .com 链接转换为新服务器上的 .de 链接(而在旧服务器上它工作正常)。
<VirtualHost 10.0.0.11:443>
SuexecUserGroup myuser myuser
DocumentRoot /home/myuser/mydomain.de/html
ServerName mydomain.de
ServerAlias www.mydomain.de ftp.mydomain.de mail.mydomain.de
ServerAdmin [email protected]
# subdomain logic
RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_HOST} !^www\.mydomain\.de [NC]
RewriteCond %{HTTP_HOST} !^mydomain\.de [NC]
RewriteCond %{HTTP_HOST} ^([A-Z0-9a-z-.]+)\.mydomain\.de [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
RewriteRule ^([0-9A-Za-z-.]+)\.mydomain\.de/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L]
RewriteCond %{HTTP_HOST} ^www\.([A-Z0-9a-z-.]+)\.mydomain\.de [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
RewriteRule ^www\.([0-9A-Za-z-.]+)\.mydomain\.de/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L]
# end subdomain logic
LogLevel debug
ErrorLog /home/myuser/var/mydomain.de/logs/error_ssl.log
CustomLog /home/myuser/var/mydomain.de/logs/transfer.log combined
# php: default don't edit between this and the "end php" comment below
<IfModule mod_suphp.c>
suPHP_Engine On
suPHP_UserGroup myuser myuser
AddHandler x-httpd-php .php
suPHP_AddHandler x-httpd-php .php
suPHP_ConfigPath /home/myuser/etc
</IfModule>
<IfModule !mod_suphp.c>
<IfModule mod_php5.c>
php_admin_flag engine On
</IfModule>
<IfModule mod_php4.c>
php_admin_flag engine On
</IfModule>
</IfModule>
# end php
# cgi: 1 don't edit between this and the "end cgi" comment below
<Directory /home/myuser/mydomain.de/html>
AllowOverride All
</Directory>
<Location />
Options +ExecCGI
</Location>
ScriptAlias /cgi-bin/ /home/myuser/mydomain.de/html/cgi-bin/
# end cgi
<IfModule mod_substitute.c>
<Location />
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|http://www.mydomain.com/|http://www.mydomain.de/|niq"
Substitute "s|http://www.mydomain.com|http://www.mydomain.de/|niq"
Substitute "s|http://mydomain.com/|http://www.mydomain.de/|niq"
Substitute "s|http://mydomain.com|http://www.mydomain.de/|niq"
Substitute "s|https://www.mydomain.com/|https://mydomain.de/|niq"
Substitute "s|https://www.mydomain.com|https://mydomain.de/|niq"
Substitute "s|https://mydomain.com/|https://mydomain.de/|niq"
Substitute "s|https://mydomain.com|https://mydomain.de/|niq"
</Location>
</IfModule>
#.com.au is the primary (CN) certificate for all country domains (multi-domain certificate)
SSLEngine on
SSLCipherSuite SSLv3:HIGH:MEDIUM:!SSLv2:!ADH:!aNULL:!eNULL:!NULL:!LOW
SSLCACertificatePath /home/myuser/var/mydomain.com.au/ssl
SSLCertificateKeyFile /home/myuser/var/mydomain.com.au/ssl/mydomain.com.au.priv.key
SSLCertificateFile /home/myuser/var/mydomain.com.au/ssl/mydomain.com.au.crt
SSLCACertificateFile /home/myuser/var/mydomain.com.au/ssl/mydomain.com.au.chain.crt
SSLOptions +ExportCertData +StrictRequire
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
通过将 Apache 升级到 2.2.23(它是 2.2.3)解决了这个问题。
新服务器上的 yum repros 未启用以允许升级超过 2.2.3-76.el5.centos,在找到正确的 repro 以启用和升级后,SSL 问题已修复。这不是配置文件问题。