You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Erik Thuning <th...@dsv.su.se> on 2025/04/23 09:41:29 UTC
[users@httpd] Apache dropping content-length response header from reverse proxy
Hi!
I'd be grateful for any insight into what seems like it must be a simple
issue, but I can't for the life of me find any answers in the
documentation or on the wider internet.
I have an apache server running as reverse proxy for a tomcat
application using mod_proxy_ajp. An external application pulling data
from mine has a hard requirement to get a content-length header in the
response and won't accept transfer-encoding=chunked. Tomcat is setting
content-length as expected, but apache replaces it with
transfer-encoding=chunked in its response.
How can I make apache stop switching these headers (and presumably stop
streaming the response)? Preferrably only for a specified path
(/divaexport), since the application is large and only a tiny portion
has this content-length requirement.
My vhost configuration looks like this:
<VirtualHost *:80>
ServerName redacted.example
# Diva is an idiot and needs to be excluded from https
RewriteEngine on
RewriteRule ^(/divaexport) - [last]
RewriteRule ^/(.*) https://daisy.dsv.su.se/$1 [redirect=301]
ProxyPass / ajp://localhost:8009/
LogFormat "%h %l %u %{%Y-%m-%d %H:%M:%S}t \"%r\" %>s %O
\"%{Referer}i\" \"%{User-Agent}i\"" isotime
CustomLog ${APACHE_LOG_DIR}/access.log isotime
</VirtualHost>
This is the response from tomcat when curl:ing it directly:
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /divaexport/fil?id=69212 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200
< Content-Disposition: inline; filename="afile.pdf"
< Content-Type: application/pdf;charset=utf-8
< Content-Language: en-GB
< Content-Length: 1820601
< Date: Wed, 23 Apr 2025 08:51:15 GMT
This is the response from apache:
* Trying redacted:80...
* Connected to redacted.example (redacted) port 80 (#0)
> GET /divaexport/fil?id=69212 HTTP/1.1
> Host: redacted.example
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 200
< Date: Wed, 23 Apr 2025 08:52:46 GMT
< Server: Apache/2.4
< Content-Disposition: inline; filename="afile.pdf"
< Content-Type: application/pdf;charset=utf-8
< Content-Language: en-GB
< Transfer-Encoding: chunked
/T
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache dropping content-length response header from reverse proxy
Posted by Erik Thuning <th...@dsv.su.se>.
On 2025-04-23 14:16, Rainer Canavan wrote:
> > From: Erik Thuning <th...@dsv.su.se>
> [...]
>
> > I have an apache server running as reverse proxy for a tomcat
> > application using mod_proxy_ajp. An external application pulling data
> > from mine has a hard requirement to get a content-length header in the
> > response and won't accept transfer-encoding=chunked. Tomcat is setting
> > content-length as expected, but apache replaces it with
> > transfer-encoding=chunked in its response.
>
> > How can I make apache stop switching these headers (and presumably stop
> > streaming the response)? Preferrably only for a specified path
> > (/divaexport), since the application is large and only a tiny portion
> > has this content-length requirement.
>
> Since chunked encoding is an integral part of HTTP/1.1, try setting
> downgrade-1.0 and/or force-response-1.0 using BrowserMatch if possible
> (see https://httpd.apache.org/docs/2.4/env.html), but I'm not sure if
> that will result a Content-Length header or a simple Connection: close
> in this case. If you really need the Content-Length, mod_buffer may be
> useful.
>
> Rainer
Downgrading only results in Connection: close unfortunately. I'll look
into mod_buffer, thanks!
/T
Re: [users@httpd] Apache dropping content-length response header from reverse proxy
Posted by Rainer Canavan <ra...@sevenval.com.INVALID>.
> From: Erik Thuning <th...@dsv.su.se>
[...]
> I have an apache server running as reverse proxy for a tomcat
> application using mod_proxy_ajp. An external application pulling data
> from mine has a hard requirement to get a content-length header in the
> response and won't accept transfer-encoding=chunked. Tomcat is setting
> content-length as expected, but apache replaces it with
> transfer-encoding=chunked in its response.
> How can I make apache stop switching these headers (and presumably stop
> streaming the response)? Preferrably only for a specified path
> (/divaexport), since the application is large and only a tiny portion
> has this content-length requirement.
Since chunked encoding is an integral part of HTTP/1.1, try setting downgrade-1.0 and/or force-response-1.0 using BrowserMatch if possible (see https://httpd.apache.org/docs/2.4/env.html), but I'm not sure if that will result a Content-Length header or a simple Connection: close in this case. If you really need the Content-Length, mod_buffer may be useful.
Rainer
— DISCLAIMER —
This email and any attachments may contain confidential information and are intended solely for the recipient. If you are not the intended recipient, please delete it and notify the sender. Unauthorized use or disclosure is prohibited.
Please note that the footer may include automatically added classification labels. These labels reflect internal handling guidelines and do not affect legal obligations.