caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.73k stars 4.05k forks source link

Websocket Question #5490

Closed taiwan-king closed 1 year ago

taiwan-king commented 1 year ago

Hello developer,

I'm a Caddy2 beginner and was able to successfully establish a WebSocket using an online testing tool at http://www.easyswoole.com/wstool.html with the testing URL at ws://test.taiwan-homecloud.work.gd.

However, I encounter errors when trying to connect via my browser at http://test.taiwan-homecloud.work.gd/.

Since I am not the developer of this game and am not familiar with the code, I am not sure what is causing the issue. However, everything runs smoothly during internal network testing.

Below is my Caddyfile configuration.

http://test.taiwan-homecloud.work.gd { @websockets { header Connection *Upgrade* header Upgrade websocket } reverse_proxy @websockets 192.168.10.253:8000 { header_up -Origin } reverse_proxy 192.168.10.253:8788 }

Thank you for your help.

log: 2023/04/12 19:10:43.144 ERROR http.log.error dial tcp 192.168.10.253:8788: connect: connection refused {"request": {"remote_ip": "142.147.89.228", "remote_port": "39734", "proto": "HTTP/1.1", "method": "GET", "host": "test.taiwan-homecloud.work.gd", "uri": "/", "headers": {"Accept-Language": ["en-US,en;q=0.9,de;q=0.8,fr;q=0.7,nl;q=0.6,lb;q=0.5,es;q=0.4,pt;q=0.3"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7"], "Sec-Ch-Ua-Mobile": ["?0"], "Cache-Control": ["max-age=0"], "User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"], "Sec-Ch-Ua-Platform": ["\"Windows\""], "Sec-Fetch-Site": ["none"], "Sec-Ch-Ua": ["\"Chromium\";v=\"110\", \"Not A(Brand\";v=\"24\", \"Google Chrome\";v=\"110\""], "Sec-Fetch-Dest": ["document"], "Accept-Encoding": ["gzip, deflate, br"], "Upgrade-Insecure-Requests": ["1"], "Connection": ["Keep-Alive"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-User": ["?1"]}}, "duration": 0.074374653, "status": 502, "err_id": "8whkrii4w", "err_trace": "reverseproxy.statusError (reverseproxy.go:1299)"}

taiwan-king commented 1 year ago

Issue has been raised at https://caddy.community/t/websocket-question/19618