Disable Apache http2 announce via htaccess

霸气de小男生 提交于 2020-02-25 06:41:06

问题


I have a website on a shared host, responding with these HTTP headers on each page request:

HTTP/1.1 200 OK
Date: Thu, 21 Sep 2017 14:34:46 GMT
Server: Apache
X-Powered-By: PHP/5.6.31
Access-Control-Allow-Origin: *
Upgrade: h2,h2c
Connection: Upgrade, Keep-Alive
Keep-Alive: timeout=5, max=400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

As you note, there is the Upgrade header that is an announce from Apache about the support of HTTP2 protocol.

For some reason, I need to disable this behavior of Apache, in order to send responses without the Upgrade header.

Who knows how to disable it from the .htaccess file? I've already found this solution:

Header unset Upgrade

But it's not the good one, since sometimes I need to output a custom Upgrade header from my code (needed to broadcast a firmware upgrade to some thermal printer devices).

Thanks


回答1:


Try turning it off with this config: https://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2upgrade.

Alternatively, for a .htaccess only solution, use the Header edit functionality:

Header edit Upgrade (.*)h2,h2c(.*) "$1$2"

Note this may leave you with an empty upgrade header, and you may have to change the config depending on what exactly is shown by your server (e.g. extra commas).



来源:https://stackoverflow.com/questions/46495192/disable-apache-http2-announce-via-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!