Bug 66391 - H2 not proxying Content-Type
Summary: H2 not proxying Content-Type
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_http2 (show other bugs)
Version: 2.4-HEAD
Hardware: All All
: P2 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2022-12-15 10:48 UTC by Jérôme Billiras
Modified: 2022-12-17 10:23 UTC (History)
0 users



Attachments
h2_proxy_session.patch (783 bytes, patch)
2022-12-15 10:48 UTC, Jérôme Billiras
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jérôme Billiras 2022-12-15 10:48:05 UTC
Created attachment 38450 [details]
h2_proxy_session.patch

Hi

I found bug in http2 proxy. Content-Type header is not set correctly if served file name match with mime.types

With simple http proxy it's handle via `mod_proxy_http.c:1302-1304`


I can reproduce this bug with a front httpd proxying to an other httpd that serving php files.

Here my test case

First httpd server: `100-httpd-proxy.conf`
> <VirtualHost *:${HTTP_PORT}>
>     ServerName localhost
> 
>     ProxyPreserveHost On
> 
>     # I use h2c instead h2 for test case for convenient but bug append also with h2
>     # I use docker containers, so httpd DNS point to second server
>     ProxyPass         /h2c/  h2c://httpd/
>     ProxyPassReverse  /h2c/  http://httpd/
> 
>     ProxyPass         /h11/  http://httpd/
>     ProxyPassReverse  /h11/  http://httpd/
> </VirtualHost>

Second httpd server: `100-httpd.conf`
> <VirtualHost *:${HTTP_PORT}>
>     ServerName localhost
> 
>     DocumentRoot /srv/httpd/app
> 
>     <Directory /srv/httpd/app>
>         Require all granted
>     </Directory>
> 
>     ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/srv/httpd/app/$1
> </VirtualHost>

`/srv/httpd/app/info.php` and `/srv/httpd/app/info.conf.php`
> <?php
>     phpinfo();


> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h11/info.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h11/info.conf.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h2c/info.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h2c/info.conf.php'
>> text/plain


I patch `h2_proxy_session.c` to have same behaviours as http1.1 proxy
After rebuild with patch I have 
> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h11/info.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h11/info.conf.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h2c/info.php'
>> text/html; charset=UTF-8

> % curl -w "%{content_type}\n" -so /dev/null 'http://localhost/h2c/info.conf.php'
>> text/html; charset=UTF-8
Comment 1 Stefan Eissing 2022-12-17 10:23:44 UTC
Thanks Jérôme for finding this and writing a patch. I added this to trunk as r1906051 and propose it for backport to the next 2.4.x release.