Apache2 SSL 网站不断重定向到默认网站

Apache2 SSL 网站不断重定向到默认网站

所以我有一个在 ubuntu 中完全正常运行的 Apache2 Web 服务器。我已成功修改 vhosts 文件以适应正常的 :80 请求,并且所有网站均正常运行。但是,一旦我尝试为 SSL 配置 vhosts,当提供 www 时,我的所有网站都会重新路由到文件中的默认(第一个)站点。例如,第一个 https 站点是 www.thepeepinghole.tk。如果我输入https://www.geekychicgirls.tk它会重新路由到 www.thepeepinghole.tk。有趣的是,如果我输入https://geekychicgirls.tk它转到正确的网站。如果有人能帮忙,我将不胜感激,我已经被这个问题困扰好几天了。非常感谢!

默认 SSL:

NameVirtualHost *:443

<IfModule mod_ssl.c>
NameVirtualHost *:443
<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "/var/www/thepeepinghole"
    SSLEngine on
    SSLCertificateFile /ssl/14252798.crt
    SSLCertificateKeyFile /ssl/private.key
    SSLCertificateChainFile /ssl/New-PositiveSSL-bundle-12.ca-bundle
    ServerName thepeepinghole.tk:443
    ServerAlias www.thepeepinghole.tk
    ErrorLog "/var/www/thepeepinghole/log/error.log"
    CustomLog "/var/www/thepeepinghole/log/access.log" common
    <Directory /var/www/thepeepinghole>
                DirectoryIndex index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
     </Directory>
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "/var/www/geekychicgirls"
    SSLEngine on
    SSLCertificateFile /ssl/14252798.crt
    SSLCertificateKeyFile /ssl/private.key
    SSLCertificateChainFile /ssl/New-PositiveSSL-bundle-12.ca-bundle
    ServerName geekychicgirls.tk:443
    ServerAlias www.geekychicgirls.tk
    ErrorLog "/var/www/geekychicgirls/log/error.log"
    CustomLog "/var/www/geekychicgirls/log/access.log" common
    <Directory /var/www/geekychicgirls>
                DirectoryIndex index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
     </Directory>
</VirtualHost>

apache2ctl -S 的输出:

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri Mar 21 23:14:49 2014] [warn] NameVirtualHost *:443 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
         default server thepeepinghole.tk (/etc/apache2/sites-enabled/000-default-ssl:5)
         port 443 namevhost thepeepinghole.tk (/etc/apache2/sites-enabled/000-default-ssl:5)
         port 443 namevhost geekychicgirls.tk (/etc/apache2/sites-enabled/000-default-ssl:24)
*:80                   is a NameVirtualHost
         default server www.bondsolutionsnj.com (/etc/apache2/sites-enabled/000-default:4)
         port 80 namevhost www.bondsolutionsnj.com (/etc/apache2/sites-enabled/000-default:4)
         port 80 namevhost www.accessorizewithstylenj.com (/etc/apache2/sites-enabled/000-default:22)
         port 80 namevhost www.futureretrogaming.com (/etc/apache2/sites-enabled/000-default:38)
         port 80 namevhost www.k9minecraft.tk (/etc/apache2/sites-enabled/000-default:56)
         port 80 namevhost www.k9proxy.tk (/etc/apache2/sites-enabled/000-default:72)
         port 80 namevhost www.thepeepinghole.tk (/etc/apache2/sites-enabled/000-default:89)
         port 80 namevhost www.geekychicgirls.tk (/etc/apache2/sites-enabled/000-default:105)
Syntax OK

Apache2 启动时警告:

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Sat Mar 22 20:18:04 2014] [warn] NameVirtualHost *:443 has no VirtualHosts

答案1

好吧,解决方案对我来说非常简单(只是花了很长时间才弄明白):)

好吧,我所做的就是

NameVirtualHost *:443
<VirtualHost *:443>
ServerName: www.mysitehere.com
ServerAlias: mysitehere.com
</VirtualHost>

我还摆脱了 if 语句。

相关内容