apache - 安装了 SSL 证书,但是当我进入我的域时,我必须包含 https ://before the URL

标签 apache ssl https

所以一直在Apache里面瞎折腾,买了个SSL证书。我终于安装了它,但现在当我使用 URL (leethecoder.com) 转到我的域时,我假设它正在尝试使用 HTTP?当然,我的带有 SSL 证书的服务器没有在端口 80 上监听。但是,如果我在 URL ( https://leethecoder.com) 之前包含 https://,它就可以工作。有没有办法让服务器强制基本 URL (leethecoder.com) 转到端口 443?

这是我当前的 /sites-enabled/ 配置文件。

LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
    ServerName www.leethecoder.com
    ServerAlias www.leethecoder.com leethecoder.com
    Options -Indexes
    DocumentRoot /var/www/leethecoder.com/public_html/
    SSLEngine on
    SSLCertificateFile /etc/ssl/leethecoder.com/leethecoder_com.crt
    SSLCertificateKeyFile /etc/ssl/private/sslkey.key
    SSLCertificateChainFile /etc/ssl/leethecoder.com/foobundle.ca-bundle
    ErrorLog /var/www/leethecoder.com/logs/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

最佳答案

IMO,是“正确的”(you're currently an A-,以下可能有助于获得 A+):

<VirtualHost *:80>
  ServerName leethecoder.com
  ServerAlias *.leethecoder.com
  UseCanonicalName Off
  ErrorLog /var/www/leethecoder.com/logs/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  RedirectPermanent / https://leethecoder.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName www.leethecoder.com
  UseCanonicalName Off
  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3
  SSLHonorCipherOrder on
  SSLCipherSuite "-ALL EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EDH+aRSA+AESGCM EECDH+ECDSA+AES EECDH+aRSA+AES EDH+aRSA+AES RSA+3DES"
  SSLCertificateFile /etc/ssl/leethecoder.com/leethecoder_com.crt
  SSLCertificateKeyFile /etc/ssl/private/sslkey.key
  SSLCertificateChainFile /etc/ssl/leethecoder.com/foobundle.ca-bundle
  ErrorLog /var/www/leethecoder.com/logs/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  RedirectPermanent / https://leethecoder.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName leethecoder.com
  UseCanonicalName Off
  ErrorLog /var/www/leethecoder.com/logs/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  DocumentRoot /var/www/leethecoder.com/public_html
  <Directory /var/www/leethecoder.com/public_html/>
    Allow From All
  </Directory>
  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3
  SSLHonorCipherOrder on
  SSLCipherSuite "-ALL EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EDH+aRSA+AESGCM EECDH+ECDSA+AES EECDH+aRSA+AES EDH+aRSA+AES RSA+3DES"
  SSLCertificateFile /etc/ssl/leethecoder.com/leethecoder_com.crt
  SSLCertificateKeyFile /etc/ssl/private/sslkey.key
  SSLCertificateChainFile /etc/ssl/leethecoder.com/foobundle.ca-bundle
</VirtualHost>

当然,这是假设您的变量有效,您更喜欢没有 www 的 https,并且您可以让您的客户使用该密码套件。此外,您已启用该网站,并禁用了任何其他有冲突的网站。

关于apache - 安装了 SSL 证书,但是当我进入我的域时,我必须包含 https ://before the URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40544280/

相关文章:

c++ - FastCGI 如何在 Web 服务器上工作(例如 Apache 2.2+)?

php - Apache 在 Mavericks 上运行错误版本的 PHP

c# - 让 IE6、7、8 通过 ssl 从我们的站点可靠地下载 office 文档

android - javax.net.ssl.SSLProtocolException : SSL handshake aborted: ssl=0x7fa6b56a00: Failure in SSL library, 通常是协议(protocol)错误

Angular/Ionic http 请求忽略 https

php - Apache 不记录 php 错误

linux - 您如何找出安装的哪些软件包具有 `apache2` 作为其依赖项?

java - eclipse 中的 SSL keystore 路径

c - 在不检查证书的情况下使用 OpenSSL,但我的数据是否仍在加密?

通过 ftps 克隆 Git