我正在和一个小团队合作,目前我们有两台服务器,一台用于发布版本,另一台用于开发。 我们有一个通配的SSL证书,所以我们可以覆盖多个子域名。 我在各自的服务器上设置了版本和开发分支,而我们原来只在活动服务器上安装了SSL,而开发版本是标准的HTTP。 现在我们希望能够在开发服务器上build立一个SSL构build,为我们提供更真实的testing环境,但是我们遇到了当前的问题。
我有活的服务器设置,以捕捉所有子域名,因为我们将向不同的组织销售我们的服务,我们希望给予他们追加到URL的机会。 当我尝试在dev服务器上为一个特定的URL设置虚拟主机时,会发生问题。 当加载的login页面在开发服务器上时,login或者踢你的SSL,或者它重新引导你到实时服务器(可能是因为我在实时服务器上的重写规则,以防止你被踢出https)。 这里是我目前的两个configuration文件。
Live服务器
<VirtualHost *:80> ServerName *.fileblimp.com RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] <IfModule pagespeed_module> ModPagespeed Off </IfModule> </VirtualHost> <VirtualHost *:443> ServerName *.fileblimp.com ServerAlias * ServerAdmin webmaster@localhost DocumentRoot /var/www/files <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined <IfModule pagespeed_module> ModPagespeed Off </IfModule> <IfModule mod_php5.c> php_value include_path ".:/usr/local/lib/php:/wwwfiles/sta$ </IfModule> SSLEngine on SSLCertificateFile /etc/apache2/ssl/certs/cert.crt SSLCertificateKeyFile /etc/apache2/ssl/private/fileblimp.com.key SSLCertificateChainFile /etc/apache2/ssl/certs/gd_bundle.crt </VirtualHost>
开发服务器
<VirtualHost *:443> ServerName development.fileblimp.com ServerAdmin webmaster@localhost DocumentRoot /var/dev/www/files <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined <IfModule pagespeed_module> ModPagespeed Off </IfModule> <IfModule mod_php5.c> php_value include_path ".:/usr/local/lib/php:/wwwfiles/sta$ </IfModule> SSLEngine on SSLCertificateFile /etc/apache2/ssl/certs/cert.crt SSLCertificateKeyFile /etc/apache2/ssl/private/fileblimp.com.key SSLCertificateChainFile /etc/apache2/ssl/certs/gd_bundle.crt </VirtualHost>
预先感谢您的帮助,我真的很感激。
Safado正确地指出,活动服务器上的应用程序似乎存在configuration错误,导致它将用户从HTTPS退回到HTTP。 如果有一个HTTP URL,像http://www.fileblimp.com ,应用程序configuration中的某处,我不会感到惊讶。 如果你解决这个问题,你可能会解决你的问题。
否则,在活动服务器上,将第一个虚拟主机中的HTTPredirect回HTTPS似乎解决了这个问题。 但是,虚拟主机似乎并不在开发服务器上。 这是故意的,还是你误解了你的问题? 这就是从HTTP到HTTPS的redirect,因此,如果您将其添加到开发服务器,解决方法也可以在那里工作。
顺便说一句,在现场服务器上,您可以通过RewriteCond %{SERVER_PORT} !^443$来简化第一个虚拟主机。 这是不需要的,因为已知<VirtualHost *:80>的服务器正在侦听端口80。
在开发中,相应的虚拟主机可以进一步简化
<VirtualHost *:80> ServerName development.fileblimp.com Redirect permanent / https://development.fileblimp.com/ </VirtualHost>