Apache 2.4 SSL 配置 - 服务器拒绝 HTTP 400 请求

标签 apache ssl apache2.4

我在使用 Apache 2.4 配置时遇到了一些问题。正在访问 https://subdomain.my-domain.com始终返回此 http 400。

Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please.

我直接通过 https 访问我的站点,因此不涉及从 http 到 https 的重定向。在我的 apache 配置下面。我知道我不检查证书的有效性。现在他们只是自签名,但将来会改变。

##################################################################
###                                                            ###
###   Global Settings                                          ###
###                                                            ###
##################################################################

    DocumentRoot /var/ebc/apache2/www/htdocs
    <Location /fwcheck.html>
        <RequireAll>
            Require all granted
        </RequireAll>
    </Location>

##################################################################
###                                                            ###
###   Global SSL Settings                                      ###
###                                                            ###
##################################################################

    SSLProtocol             ALL -SSLv2 -SSLv3
    SSLProxyProtocol        ALL -SSLv2 -SSLv3
    SSLHonorCipherOrder     on
    SSLCipherSuite          ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:HIGH:!MD5:!aNULL:!EDH
    SSLCompression          off
    SSLSessionTickets       off

    # OCSP Stapling, only in httpd 2.3.3 and later
    SSLUseStapling                      on
    SSLStaplingResponderTimeout         5
    SSLStaplingReturnResponderErrors    off
    SSLStaplingCache                    shmcb:/var/ebc/apache2/sslstaplingcache(128000)

##################################################################
###                                                            ###
###   Virtual Hosts                                            ###
###                                                            ###
##################################################################

<VirtualHost 10.173.144.43:80>
    ErrorLog /var/ebc/apache2/log/error.log
    CustomLog /var/ebc/apache2/log/access.log vhost_combined

    ##################################################################
    ###                                                            ###
    ###   Send everything to https except firewall check           ###
    ###   vhost config only for port 443 necessary.                ###
    ###   No further config for port 80.                           ###
    ###                                                            ###
    ##################################################################

        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !fwcheck.html
        RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

    ##################################################################
</VirtualHost>

<VirtualHost 10.173.144.43:443>
    ServerName subdomain.my-domain.com
    ErrorLog /var/ebc/apache2/log/error.log
    CustomLog /var/ebc/apache2/log/access.log vhost_combined

    ##################################################################
    ###                                                            ###
    ###   SSL Settings                                             ###
    ###                                                            ###
    ##################################################################

        RequestHeader set ClientProtocol HTTPS
        SSLEngine       On
        SSLProxyEngine  On

        SSLCertificateFile      /var/ebc/apache2/ssl/subdomain.my-domain.com.crt
        SSLCertificateKeyFile   /var/ebc/apache2/ssl/subdomain.my-domain.com.key
        SSLCACertificateFile    /var/ebc/apache2/ssl/subdomain.my-domain.com.crt

        ProxyRequests       off
        ProxyPreserveHost   on

        # Disable certificate checks
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off

        # HSTS (15768000 seconds = 6 months)
        Header always set Strict-Transport-Security "max-age=15768000"

    ##################################################################
    ###                                                            ###
    ###   Locations                                                ###
    ###                                                            ###
    ##################################################################

        DocumentRoot /var/ebc/apache2/www/htdocs/prod

        <Location />
            Options None
            <RequireAll>
                Require all granted
            </RequireAll>
        </Location>

        <Location /web-status>
            <RequireAll>
                Require all denied
            </RequireAll>
        </Location>

        <Location /balancer-manager>
            <RequireAll>
                Require all denied
            </RequireAll>
        </Location>

    ##################################################################
</VirtualHost>

我真的不知道为什么这不起作用。谁能给我一个提示?

在此先感谢大家并问候塞巴斯蒂安

最佳答案

您的连接未到达接口(interface) 10.173.144.43:443,因此它未由您的 VirtualHost 处理。它命中未启用 SSL 的主服务器配置。

如果您不关心使用什么本地接口(interface),请在 VirtualHost 中使用 *

关于Apache 2.4 SSL 配置 - 服务器拒绝 HTTP 400 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34786436/

相关文章:

linux - 如何在 Ubuntu 服务器上设置权限以允许 Apache 用户和第二个用户写入 Web 目录?

Javascript - 当页面使用 SSL 时复选框不起作用(使用 Kentico CMS)

laravel - 除了主页之外,我的 Laravel 项目中没有其他可访问的内容

websocket - 无法将模块/mod_proxy_wstunnel.so 加载到服务器中

https - httpd 文件夹不存在

mysql - Not Acceptable 在此服务器上找不到所请求资源的适当表示。此错误是由 Mod_Security 生成的

php - Htaccess 重写目录到文件

windows - Apache/Windows 上的 Mercurial 服务器

Java 1.8 : TLSv1. 2 ClientHello 握手失败(缺少椭圆曲线扩展?)

node.js - 使用 SSL over TCP 在带有 NodeJS 的两台服务器之间建立安全连接