skip to Main Content

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.

2

Answers


  1. Virtual Host file configuration:

      <VirtualHost *:443>
        ServerAdmin [email protected]
        ServerName example.com
        ServerAlias www.example.com
    
        ssl_certificate .....
        ssl_certificate_key ..........
    
      ProxyRequests Off Order deny, allow Allow from all
     <Location />
            ProxyPass http://example.com:8000/
            ProxyPassReverse http://example.com:8000/
        </Location>
    
    </VirtualHost>
    

    Next we need to enable a few Apache modules. To do this, issue the following commands:

    sudo a2enmod proxy

    sudo a2enmod proxy_http

    sudo a2enmod proxy_balancer

    sudo a2enmod lbmethod_byrequests

    Apache will now need to be restarted with the command:

    sudo service apache2 restart

    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search