Caddy Reverse proxy websocket error on UNRAID

Hi everybody,

I switched from Freenas to UNRAID. I set up Caddy in a container. I also set up a reverse proxy, however I am unable to get HomeAssistant running on it. The page loads up fine, however when I enter the password, the loading circle just spins forever.

I get the following error in console: WebSocket connection to ‘wss://mysite.com/api/websocket?latest’ failed: Error during WebSocket handshake: Unexpected response code: 502

This is how my Caddyfile looks like for this instance:

mysite.com {
proxy / http://192.168.2.3:8123 {
websocket
transparent
}
}

I have also tried many variations to no avail. I’m happy to provide my site information and password (over PM).

This worked perfectly on FreeNAS, so I’m not sure where the culprit is.

If anybody can point me to the right direction, I would really appreciate it!

Can you post the output of:

curl -i -N -v -H “Connection: Upgrade” -H “Upgrade: websocket” -H “Host: mysite.com” -H “Origin: https://mysite.comhttps://mysite.com/api/websocket?latest

Or if you dont have curl the headers from both the UNRAID side and the caddy side of the situation?

@SpiraMirabilis, thank you for your reply!

Unfortunately, it doesn’t output anything:

Thats because you didnt close a quotation mark somewhere. Maybe that last -H with the Origin? Make sure they’re " quotes or single quotes ’ and not the unicode open and end quotes (“”) that I just had to edit out of this post.

Writing it like this in a text editor can help debug long commands:

curl -i -N -v \
-H ‘Connection: Upgrade’ \
-H ‘Upgrade: websocket’ \
-H ‘Host: mysite.com’ \
-H ‘Origin: https://mysite.com’ \
https://mysite.com/api/websocket?latest

Tried the single quotations with no luck as well:

image

I do this on my UNRAID IP, right? I have UNRAID running on 192.168.2.3, however CADDY is running on its own IP at 192.168.2.19.

Both, preferably. So caddy operates on .19 as a reverse proxy to a websocket resource on .3? You can access both things simultaneously? If so, you might be able to just use https://caddyserver.com/docs/http.filter to search for and replace the URL that caddy is not proxying properly with the .19 address equivalent and skip the middleman as it were.

This would only work while you’re inside your network of course, if you were planning on accessing this from the internet via caddy as a traditional reverse-proxy well we’d have to find out whats wrong.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.