Bug 63132

Summary: Allow ProxyPass directives of the same URL to be chained
Product: Apache httpd-2 Reporter: Mina Galić <me>
Component: mod_proxy_httpAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal CC: me
Priority: P2    
Version: 2.4.38   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Mina Galić 2019-01-30 11:14:33 UTC
These days it's quite common to have applications served over both http(s) and WebSockets, however, it's impossible to realize this with mod_proxy alone, since its directives (of the same URL) cannot be chained

We have to resolve to mod_rewrite (and mod_rewrite only!) since the protocol cannot be made dynamic (see https://bz.apache.org/bugzilla/show_bug.cgi?id=55315#c5) — e.g.:

RewriteEngine on
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://backend:64080/$1 [P,L]
ProxyPass / http://backend:64080/quassel


mod_proxy_* submodules end their request in DECLINED, which seems the main reason (that I'm aware of) why we cannot chain ProxyPass directives:

ProxyPass / ws://backend:64080/
ProxyPass / http://backend:64080/

On the other hand, DECLINED is a good default, so perhaps we should introduce this as feature flag! mod_rewrite has `[Last]` so perhaps we could add `continue`?

ProxyPass / ws://backend:64080/ continue
ProxyPass / http://backend:64080/
Comment 1 Yann Ylavic 2019-02-19 21:01:14 UTC
I opened this thread a while ago: https://lists.apache.org/thread.html/e441f75818d07112e8122232440752bd8c27d5539b199bcd115e3b4e@%3Cdev.httpd.apache.org%3E

It seems to me that Websockets (and Upgrade-d protocols in general) should be forwarded by mod_proxy_http itself, once (and only once) it knows that the upgrade has been accepted on the backend side (Upgrade is part of the HTTP protocol after all).

If it makes sense, I can try to revive the patch proposed in the above thread...
Comment 2 Mina Galić 2019-02-25 14:02:47 UTC
please do.

Reading that mail thread, i do not believe i would have the energy to do that…