简体   繁体   English

HTTP2可用,但服务器拒绝使用它为什么会这样?

[英]HTTP2 is available but server refuses to use it why it may be?

I have successfully set up http2 for my virtual host but when I try to access the url via curl it looks like server refuses connection over http2 and accepts http1. 我已经成功为我的虚拟主机设置了http2但是当我尝试通过curl访问url时,看起来服务器拒绝通过http2连接并接受http1。 Can anyone explain why it may be? 任何人都可以解释为什么会这样吗? and how can I tell my server to use http2 in the first place. 我怎样才能告诉我的服务器首先使用http2。

Below is the curl output of the site I am trying to configure http2 for. 下面是我试图配置http2的网站的卷曲输出。

* Rebuilt URL to: https://example.com/
*   Trying 172.24.112.31...
* TCP_NODELAY set
* Connected to example.com (172.24.112.31) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [221 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [112 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
    { [2426 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [300 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [37 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: OU=Domain Control Validated; CN=*.example.com
*  start date: Jun  9 09:24:31 2016 GMT
*  expire date: Jun 10 09:24:31 2019 GMT
*  subjectAltName: host "example.com" matched cert's     "*.example.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Domain Validation CA - SHA256 - G2
*  SSL certificate verify ok.
} [5 bytes data]
> GET / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
{ [5 bytes data]
< HTTP/1.1 302 Found
< Date: Thu, 08 Mar 2018 08:54:23 GMT
< Server: Apache/2.4.29 (Ubuntu)
< Location: https://example.com
< Content-Length: 315
< Content-Type: text/html; charset=iso-8859-1
< 
{ [315 bytes data]
* Connection #0 to host example.com left intact

Below two lines are of my focus here, 以下两行是我的重点,

* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1

even though http2 is available it is not used by server but http1.1 is used. 即使http2可用,它也不会被服务器使用,但会使用http1.1。 Please help me to understand this and configure http2 the right way. 请帮助我理解这一点,并以正确的方式配置http2。

Thanks! 谢谢!

I found solution over Internet and I am updating this to help people who encounter the same problem. 我在互联网上找到了解决方案,我正在更新这个以帮助遇到同样问题的人。 when I examined the apache errorlog file, I found a warning that goes like... 当我检查apache errorlog文件时,我发现了一个类似于......的警告

[http2:warn] [pid 8494] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.

Then After an hour of googling, I came to know that this is an issue with the prefork module while configuring HTTP2.0 on apache. 然后经过一个小时的谷歌搜索,我发现在apache上配置HTTP2.0时这是prefork模块的问题。 You can find more on this particular issue and a detailed steps to configure http2 at this location. 您可以在此特定问题上找到更多信息,并在此位置配置http2的详细步骤 .

If you don't want to have any troubles while configuring http2 I hope this document will help you for sure. 如果您在配置http2时不想遇到任何麻烦,我希望本文档能够为您提供帮助。

I followed those steps and my problem was solved. 我按照这些步骤,我的问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM