theme.park icon indicating copy to clipboard operation
theme.park copied to clipboard

Caddy v2 header replacement causes websockets to stop working.

Open lue30499 opened this issue 1 year ago • 3 comments

Describe the bug Caddy v2 header replacement causes websockets to stop working. Is there a way that search pattern or replacement part can not wipeout the websocket headers?

Theme Install Method (Don't skip)

Application Info

  • Version caddy 2.5.2

This doesn't allow websockets to work in caddy v2

....
        @sonarr host sonarr.domain.tld
        handle @sonarr {
                authorize with default_policy
                filter {
                        content_type text/html.*
                        search_pattern </head>
                        replacement "<link rel='stylesheet' type='text/css' href='https://theme-park.dev/css/base/sonarr/plex.css'></head>"
                }
                reverse_proxy http://srv-l-01.internal.domain:8989 {
                        header_up -Accept-Encoding
                }
        }
....

But this does allow websockets to work in caddy v2

....
        @sonarr host sonarr.domain.tld
        handle @sonarr {
                authorize with default_policy
#                filter {
#                        content_type text/html.*
#                        search_pattern </head>
#                        replacement "<link rel='stylesheet' type='text/css' href='https://theme-park.dev/css/base/sonarr/plex.css'></head>"
#                }
                reverse_proxy http://srv-l-01.internal.domain:8989 {
                        header_up -Accept-Encoding
                }
        }
....

Expected behavior websockets to work

Screenshots Screenshot from 2022-08-04 23-45-07

Desktop (If applicable) (please complete the following information):

  • OS: All
  • Browser: All

lue30499 avatar Aug 04 '22 13:08 lue30499

@jef Any tips?

GilbN avatar Aug 13 '22 19:08 GilbN

@GilbN I haven't ran into this yet. I can play around with it when I come from vacation.

jef avatar Aug 13 '22 19:08 jef

This is a known issue with caddy2-filter, dont think you can really work around it, doesnt seem to be the case. Answered/explained by the plugin dev here sjtug/caddy2-filter#10, would be nice if we could find a solution to it though.

calmcacil avatar Sep 13 '22 17:09 calmcacil

This is a known issue with caddy2-filter, dont think you can really work around it, doesnt seem to be the case. Answered/explained by the plugin dev here sjtug/caddy2-filter#10, would be nice if we could find a solution to it though.

Thanks for the update.

Closing this based on the info above.

GilbN avatar Oct 08 '22 13:10 GilbN

@GilbN Not sure why you closed this when its not fixed. I know caddy2-filter isn't your project but your documention says to use this plugin but it breaks basic functionality of WS.

Is there another plugin? Is there another way to do this with caddy?

Regards, Lue.

lue30499 avatar Oct 08 '22 13:10 lue30499

@GilbN Not sure why you closed this when its not fixed. I know caddy2-filter isn't your project but your documention says to use this plugin but it breaks basic functionality of WS.

Is there another plugin? Is there another way to do this with caddy?

Regards, Lue.

Switch to nginx. Caddy doesn't support subfiltering with websockets. What do you want me to do about it.

GilbN avatar Oct 08 '22 14:10 GilbN

@GilbN "Switch to nginx." Ok I will probably do that.

"What do you want me to do about it." Probably remove caddy from the docs as a support proxy for sonarr, radarr and anything that uses WS.

Made me believe it would work without issue...

lue30499 avatar Oct 08 '22 14:10 lue30499