【问题标题】:HTTP/2 on Apache (Ubuntu 14.04) does not workApache (Ubuntu 14.04) 上的 HTTP/2 不起作用
【发布时间】:2016-12-15 11:51:27
【问题描述】:

我已经尝试了很多关于如何在 apache 服务器上启用 http2 的教程;例如:

但没有成功。

这是我的配置:

$ apache2 -v
Server version: Apache/2.4.23 (Ubuntu)

$ apachectl -M
Loaded Modules:
...
http2_module (shared)
...
ssl_module (shared)
...

这是我的 /etc/apache2/sites-available/default-ssl.conf

<IfModule mod_ssl.c>
    <VirtualHost *:443>

        ServerAdmin info@example.net
        DocumentRoot /var/www/html
        ServerName example.net 
        ServerAlias www.example.net

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1

        Protocols h2 http/1.1

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.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
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    </VirtualHost>
</IfModule>

当我尝试在 chrome 中加载我的页面 (https://example.net) 时,我可以看到这个响应标题:

HTTP/1.1 200 OK
Date: Tue, 09 Aug 2016 12:05:08 GMT
Server: Apache/2.4.23 (Ubuntu)
Upgrade: h2
Connection: Upgrade, Keep-Alive
Last-Modified: Thu, 30 Jun 2016 14:22:30 GMT
ETag: "b18-5367f99a49580-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 538
Keep-Alive: timeout=5, max=100
Content-Type: text/html

我错过了什么吗?你能给我一些提示吗?

【问题讨论】:

    标签: apache ubuntu http2


    【解决方案1】:

    定义“不起作用”。我看到了升级标题,所以我觉得不错。

    我怀疑 HTTPS 设置有问题。

    您使用的是 openssl 1.0.1 并使用 Chrome (which requires openssl 1.0.2 for ALPN support)。在 Firefox 或 Opera 中检查以确认。

    或者 2 您使用的是较旧的密码 blacklisted under http/2。添加以下配置以在可能的情况下强制进行适当的 HTTPS 配置:

    SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+AES128:EECDH+AES256:+SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RSA+3DES:!DSS"
    

    【讨论】:

    • 感谢您的评论。我已经生成了很多不同的密钥,但没有成功。我已经将 Ubuntu 从 14.04 更新到 16.04,瞧。现在可以了。
    【解决方案2】:

    将 Ubuntu 14.04 更新到 16.04 做到了!

    【讨论】:

    • 对我来说并不是真正的答案:(我也使用 ondrej ppa,一切都准备好了,但仍然超过 1.1
    【解决方案3】:

    您是否已将Protocols h2 h2c http/1.1 添加到/etc/apache2/apache2.conf ?

    这对我有用。

    之前它只在启用站点的 conf 中。

    【讨论】:

      猜你喜欢
      • 2018-01-27
      • 1970-01-01
      • 2012-08-21
      • 2023-03-04
      • 2015-07-01
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多