Having a heck of a time trying to enable Websockets with Caddy on a Snap Install

Here is my server info. This was installed with Snaps on Ubuntu

Key : Value
backup-on-refresh : disable
ignore-errors : false
mongo-oplog-url : mongodb://localhost:27017/local
mongo-url : mongodb://localhost:27017/parties
port 3000
siteurl myserver

Here is my caddy file config

myserver.com {

# Enable HTTPS
tls {
    dns route53
}

# Proxy WebSocket connections to your Rocket.Chat server
reverse_proxy /websocket http://localhost:3000/websocket {
    header_up Host {host}
    header_up X-Real-IP {remote}
    header_up X-Forwarded-Proto {scheme}
    header_up X-Forwarded-For {remote}
    header_up Connection {>Connection}
    header_up Upgrade {>Upgrade}
    header_up Origin {>Origin}
}

}

Here is the error message I am getting when I replace the BLANK caddyfile with the updated one

× snap.rocketchat-server.rocketchat-caddy.service - Service for snap application rocketchat-server.rocketchat-caddy
Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-caddy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-02-05 22:27:09 UTC; 22s ago
Process: 514596 ExecStart=/usr/bin/snap run rocketchat-server.rocketchat-caddy (code=exited, status=1/FAILURE)
Main PID: 514596 (code=exited, status=1/FAILURE)
CPU: 54ms

systemd[1]: snap.rocketchat-server.rocketchat-caddy.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: snap.rocketchat-server.rocketchat-caddy.service: Failed with result ‘exit-code’.
systemd[1]: snap.rocketchat-server.rocketchat-caddy.service: Scheduled restart job, restart counter is at 5.
systemd[1]: Stopped Service for snap application rocketchat-server.rocketchat-caddy.
systemd[1]: snap.rocketchat-server.rocketchat-caddy.service: Start request repeated too quickly.
systemd[1]: snap.rocketchat-server.rocketchat-caddy.service: Failed with result ‘exit-code’.
systemd[1]: Failed to start Service for snap application rocketchat-server.rocketchat-caddy.

If I then replace the updated Caddyfile with a BLANK Caddyfile everything works again. But that is not what I want. I want to enable Websockets because whenever I try to run a custom app on my server I get this error message:
error=EOF wsURL="wss://myserver.com:3000/websocket

Obviously if solved I’d replace myserver with my actual https:// server address. I feel like an idiot because I installed this using Snaps and I should have used Docker I guess. I already have had the server up and running for months now and I dont want to recreate all the users. I assume i’d have to move over the mongodb?

If you want to enable Websockets on your Rocket.Chat server, make sure your Caddyfile is correctly configured. Check if the WebSocket proxy settings are accurate, including the path and port. Also ensure your DNS settings and TLS certificates are properly configured for HTTPS. Avoid switching server setups if your current one works, but ensure backups are in place for MongoDB.

Thank you for your response and you do seem polite, however I have supplied the error message, and the original caddyfile.

I need a solution on what to do with the caddyfile. The configuration is clearly the issue here.

If the caddyfile is BLANK it works, which means the default configuration is working. HTTPS is definitely workin because the server has used HTTPS for months and has worked for months.

Hmm this is going nowhere. Here is the message that is displayed when I use a BLANK caddyfile

nap.rocketchat-server.rocketchat-caddy.service - Service for snap application rocketchat-server.rocketchat-caddy
Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-caddy.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-02-08 22:04:16 UTC; 19min ago
Main PID: 387 (start_caddy.sh)
Tasks: 8 (limit: 4442)
Memory: 83.5M
CPU: 3.749s
CGroup: /system.slice/snap.rocketchat-server.rocketchat-caddy.service
├─387 /bin/bash /snap/rocketchat-server/1602/bin/start_caddy.sh
└─710 caddy2 reverse-proxy --change-host-header --from=https://myservername.com --to=http://127.0.0.1:3000

Feb 08 22:04:45 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429885.3187242,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:45 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429885.7395024,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:47 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429887.2157943,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:47 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429887.5334787,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:47 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429887.6165545,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:48 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429888.1892583,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:48 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429888.4584205,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:48 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429888.5101721,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:48 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429888.6714916,“logger”:“http.log.error”,“msg”:“dial tcp 127.0.0.1:3000: connect: connection refused”,"reques>
Feb 08 22:04:48 [IP_ADDRESS] rocketchat-server.rocketchat-caddy[710]: {“level”:“error”,“ts”:1707429888.7319

Just received this from a Caddy rep.

"This is telling me that Caddy isn’t able to connect to the upstream app. That doesn’t seem like a problem with Caddy specifically.

I don’t think I can help any further, clearly RocketChat is doing some fancy things to wrap running Caddy, so I can’t offer support with that. You should ask the RocketChat community for help with this."

At this point should I start a new thread in the bug report forum?

I know we aren’t supposed to bump threads, but is this common? This seems to be the only place to get support for rocket chat installs and issues they may or may not have. Is there a separate community where I could perhaps get an answer?