Apache2,多个 IP,多个 vhost 一个 SSL

Apache2,多个 IP,多个 vhost 一个 SSL

我正在设置基于 debian squeeze 的 apache2 服务器。我想使用多个 IP 为多个网站提供服务。其中一些网站需要证书(每个网站一个证书)。

嗯,我的服务器有 3 个 IP(假设 0.0.0.0、1.1.1.1 和 2.2.2.2)

我已经为 0.0.0.0 和 1.1.1.1 IP 设置了多个虚拟主机,其中一个使用 SSL 证书

现在,我使用以下场景。正在服务的文件夹之一是 /home/apache/SITES。我想要的是当用户点击http://2.2.2.2/mysite重定向到 https://2.2.2.2/mysite (服务于 /home/apache/SITES/one)当他点击http://2.2.2.2/my2site重定向到 https://2.2.2.2/my2site (服务于 /home/apache/SITES/two)

到目前为止我都使用这个配置。

<VirtualHost _default_ 2.2.2.2:80>
        DocumentRoot /home/apache/SITES/default/htdocs


        Alias /mysite /home/apache/SITES/one

        <IfModule mod_rewrite.c>
        <IfModule mod_ssl.c>
                <Location /mysite>
                RewriteEngine on
                RewriteCond %{HTTPS} off
                RewriteRule ^(.*)$ https://%{HTTP_HOST}/mysite [R]
                </Location>
        </IfModule>
        </IfModule>

        <Directory /home/apache/SITES/one>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                DirectoryIndex index.php
        </Directory>


        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel error
        ErrorLog  /home/apache/SITES/logs/error.log
        CustomLog /home/apache/SITES/logs/access.log combined

</VirtualHost>

但似乎不起作用。Firefox 返回

The connection was reset
The connection to the server was reset while the page was loading.

有任何想法吗?

谢谢

答案1

您的服务器似乎没有监听端口 443。您是否还为 HTTPS 配置了虚拟主机?例如

Listen 443
NameVirtualHost 1.1.1.1:443
<VirtualHost 1.1.1.1:443>
    SSLCertificateKeyFile   ...
    SSLCertificateFile      ...
    ...
</VirtualHost>

相关内容