Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache reverse proxy by HTTP/2 will lost MIME-type and use default

English is not my native language, please excuse typing errors.

I configure Apache reverse proxy as follow, and it works fire.

ProxyRequests Off
SSLEngine On
SSLProxyEngine On

ProxyPass / https://example.com/
ProxyPassReverse / https://example.com/

And my website (PHP) support HTTP/2, so I want to proxy it by HTTP/2.

I enable mod_proxy, mod_proxy_http, mod_ssl, mod_http2, mod_proxy_http2 and others some modules. And set .php MIME-type as application/x-httpd-php.

AddType application/x-httpd-php .php

VirtualHost is follow:

<VirtualHost *:443>
    DocumentRoot "/path/to/wwwroot/"
    ServerName localhost:443

    ProxyRequests Off
    SSLEngine On
    SSLProxyEngine On

    ProxyPass / h2://example.com/
    ProxyPassReverse / https://example.com/

    # Cert
    SSLCertificateFile ...
    SSLCertificateKeyFile ...
</VirtualHost>

The different is ProxyPass / https://example.com/ to ProxyPass / h2://example.com/.

Response header Content-Type in Browser always get default MIME-type.

You can find example at phpMyAdmin Demo, filter whitelist.php in DevTools, this file Content-Type is text/javascript.

Proxy it by HTTP/2, the Content-Type become application/x-httpd-php, it lost source MIME-type text/javascript.

And proxy it by HTTP/1.1, it works well.

How can I reslove this problem?

Thank you.

like image 294
Nico Maki Avatar asked Nov 23 '25 08:11

Nico Maki


1 Answers

It’s an old question but I ran with same problem and decide to investigate.

I found a bug in http2 proxy.

It will be fixed in next HTTPD release (2.4.55)

like image 67
Bil Avatar answered Nov 26 '25 03:11

Bil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!