【问题标题】:Apache2 SSL Configuration with Virtual Hosts on Ubuntu 14.xUbuntu 14.x 上使用虚拟主机的 Apache2 SSL 配置
【发布时间】:2016-10-29 05:31:45
【问题描述】:

我希望只有 https 流量。我希望所有这些都被驱动到https://example.com 和https://www.example.com。

目前这是可行和不可行的:

https://www.example.com - 好的! http://www.example.com - 出于某种原因在我的 webroot 中显示文件列表 https://example.com - 无法访问此站点/example.com 拒绝连接。 http://example.com - example.com 页面无法正常工作。 example.com 没有发送任何数据。

我使用的是 Ubuntu 14(值得信赖),这是我当前启用的虚拟主机配置:

<IfModule mod_ssl.c>
       <VirtualHost xxx.xxx.xxx.xxx:443>
               ServerAdmin info@example.com
               ServerName www.example.com:443
               ServerAlias example.com:443

               DocumentRoot /var/www/example.com/public_html

              SSLEngine on
              SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
              SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

              <FilesMatch "\.(cgi|shtml|phtml|php)$">
                              SSLOptions +StdEnvVars
              </FilesMatch>

              <Directory /usr/lib/cgi-bin>
                              SSLOptions +StdEnvVars
             </Directory>
             BrowserMatch "MSIE [2-6]" \
                             nokeepalive ssl-unclean-shutdown \
                             downgrade-1.0 force-response-1.0
             # MSIE 7 and newer should be able to use keepalive
             BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
     </VirtualHost>
</IfModule>

任何帮助都非常感谢!

【问题讨论】:

    标签: apache ubuntu ssl virtualhost


    【解决方案1】:

    您是否尝试过永久重定向? https://wiki.apache.org/httpd/RedirectSSL

    【讨论】:

    • 谢谢。我没有启用 000-default.conf 并且配置也不正确。我在下面添加到 000-default.conf 并启用它并且它可以工作。非常感激!永久重定向/example.com
    • 似乎只有我的首页有效,而它下面的所有其他页面现在都说,“未找到请求的 URL /phpinfo.php 在此服务器上未找到。Apache/2.4.7 (Ubuntu) 服务器位于www.example.com 端口 443
    • 对不起,它有效。我必须更改所有外部资源才能从 https 中获取。谢谢!
    猜你喜欢
    • 2012-03-18
    • 2014-10-29
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    相关资源
    最近更新 更多