Bug 65361 - 101 Switching Protocols - custom headers are not set
Summary: 101 Switching Protocols - custom headers are not set
Status: RESOLVED CLOSED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_wstunnel (show other bugs)
Version: 2.4.38
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-07 10:05 UTC by steffen.probst
Modified: 2021-06-09 13:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description steffen.probst 2021-06-07 10:05:41 UTC
We are using mod_proxy_wstunnel to reverse proxy WebSocket connections via Apache to our backend. We also use the "Header" directive to always set the Strict-Transport-Security header:

Header always set Strict-Transport-Security "max-age=31536000"

We now found that certain responses don't contain the custom header. Especially 304 Not Modified doesn't contain it, which is explained in the RFC: https://datatracker.ietf.org/doc/html/rfc2616#section-10.3.5

101 Switching Protocols doesn't contain the header as well for which I couldn't find a sound explanation.

Is this a bug or am I missing a good reason why responses with status code 101 shouldn't contain any further headers?
Comment 1 Ruediger Pluem 2021-06-07 13:01:02 UTC
This should be fixed in 2.4.48. WS tunneling is now handled by mod_proxy_http unless you configure ProxyWebsocketFallbackToProxyHttp  off.
Comment 2 Yann Ylavic 2021-06-07 14:07:31 UTC
The interim responses are passed through connection filters only  (AP_FTYPE_CONNECTION), so I think that mod_headers does not see them (even with latest 2.4.48), thus the Header directive is ineffective here.

I can't find anything about HSTS and interim responses, but for "101 Switching Protocols" in particular I don't think it makes much sense anyway when the protocol is to change to something not HTTP suposedly.
Comment 3 Ruediger Pluem 2021-06-07 14:55:14 UTC
(In reply to Yann Ylavic from comment #2)
> The interim responses are passed through connection filters only 
> (AP_FTYPE_CONNECTION), so I think that mod_headers does not see them (even
> with latest 2.4.48), thus the Header directive is ineffective here.
> 

I guess you are correct. I missed that ap_send_interim_response uses r->connection->output_filters instead of r->output_filters.
Comment 4 Yann Ylavic 2021-06-07 15:28:11 UTC
(In reply to steffen.probst from comment #0)
> We now found that certain responses don't contain the custom header.
> Especially 304 Not Modified doesn't contain it, which is explained in the
> RFC: https://datatracker.ietf.org/doc/html/rfc2616#section-10.3.5

Possibly 2.4.38 did something wrong with 304 and headers set by the Header directive, though by reading the current code I think it should work with latest 2.4 (.48).
Comment 5 steffen.probst 2021-06-07 15:38:52 UTC
Thanks a lot for your quick responses. I really appreciate all your useful input!

We will test the behavior with the latest version and then I will update the status of the bug accordingly.

Thanks again!
Comment 6 steffen.probst 2021-06-08 14:46:07 UTC
Definitely resolved as of 2.4.48 for responses with status code 304 Not Modified.

Thanks again!
Comment 7 steffen.probst 2021-06-09 08:24:33 UTC
(In reply to Yann Ylavic from comment #4)
> Possibly 2.4.38 did something wrong with 304 and headers set by the Header
> directive, though by reading the current code I think it should work with
> latest 2.4 (.48).

Can you tell me the version with which the bug was initially fixed? I tried to find something in the changelog but don't really know what I am exactly looking for.
Comment 8 Ruediger Pluem 2021-06-09 13:40:50 UTC
(In reply to steffen.probst from comment #7)
> (In reply to Yann Ylavic from comment #4)
> > Possibly 2.4.38 did something wrong with 304 and headers set by the Header
> > directive, though by reading the current code I think it should work with
> > latest 2.4 (.48).
> 
> Can you tell me the version with which the bug was initially fixed? I tried
> to find something in the changelog but don't really know what I am exactly
> looking for.

This should be bug 61820