Problem with https / Bad gateway error

Description

I have a problem with running the https connection. Everything worked well and it stopped after LetsEncrypt failed to update the certificate.
Currently, everything works with an unencrypted connection (http://myserverdomain:8080). The new certificate files are defined in the Caddyfile (wildcard certificate) and are loaded correctly. When I try to change the configuration in Caddyfile to https, I get the “502 Bad gateway” error.
I do not know how to fix it.
I do not know linux very well, so I am asking for an easy answer :slight_smile:

Current Caddyfile configuration:
http:// myserverdomain:8080

tls ./cert.pem ./key.pem

proxy /localhost:3000 {
WebSocket
banner
}

Configuration with encryption enabled:
https:// myserverdomain
tls ./cert.pem ./key.pem
proxy /localhost:3000 {
WebSocket
banner
}

Server Setup Information

  • Version of Rocket.Chat Server: 1.1.3
  • Operating System: Ubuntu 18.04
  • Deployment Method: snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: 8.11.4
  • MongoDB Version: 3.4.20
  • Proxy: nginx/caddy
  • Firewalls involved: hardware firewall, ports 80, 8080, 3000, 443 are open

Any additional Information

Statuses of launched services:

administrator@ubuntu-chat:/var/snap/rocketchat-server/current$ sudo systemctl status snap.rocketchat-server.rocketchat-server.service
● snap.rocketchat-server.rocketchat-server.service - Service for snap application rocketchat-server.rocketchat-server
Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-server.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-07-24 11:58:20 CEST; 23h ago
Main PID: 1287 (startRocketChat)
Tasks: 11 (limit: 9462)
CGroup: /system.slice/snap.rocketchat-server.rocketchat-server.service
├─1287 /bin/bash /snap/rocketchat-server/1384/bin/startRocketChat
└─1421 node /snap/rocketchat-server/1384/main.js

Jul 25 11:00:01 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Not running “Generate download files for user data” again.
Jul 25 11:00:01 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Not running “Remove users from Token Channels” again.
Jul 25 11:00:01 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Not running “Generate and save statistics” again.
Jul 25 11:00:01 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Finished “Generate and save statistics”.
Jul 25 11:15:00 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Starting “Generate download files for user data”.
Jul 25 11:15:00 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Finished “Generate download files for user data”.
Jul 25 11:15:00 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Not running “Generate download files for user data” again.
Jul 25 11:15:00 ubuntu-chat rocketchat-server.rocketchat-server[1287]: server.js:207 SyncedCron ➔ info Not running “Generate download files for user data” again.
Jul 25 11:23:28 ubuntu-chat rocketchat-server.rocketchat-server[1287]: The endpoint “emoji-custom” is deprecated and will be removed after version v1.12.0
Jul 25 11:23:28 ubuntu-chat rocketchat-server.rocketchat-server[1287]: The endpoint “emoji-custom” is deprecated and will be removed after version 1.12.0

administrator@ubuntu-chat:/var/snap/rocketchat-server/current$ sudo systemctl status snap.rocketchat-server.rocketchat-caddy
● 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: active (running) since Wed 2019-07-24 12:04:07 CEST; 23h ago
Main PID: 2290 (caddy)
Tasks: 12 (limit: 9462)
CGroup: /system.slice/snap.rocketchat-server.rocketchat-caddy.service
└─2290 caddy -conf=/var/snap/rocketchat-server/1384/Caddyfile

Jul 24 12:04:07 ubuntu-chat systemd[1]: Started Service for snap application rocketchat-server.rocketchat-caddy.
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: Activating privacy features… done.
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: http:// myserverdomain:8080
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with “ulimit -n 8192”.

administrator@ubuntu-chat:/var/snap/rocketchat-server/current$ sudo systemctl status snap.rocketchat-server.rocketchat-caddy.service
● 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: active (running) since Wed 2019-07-24 12:04:07 CEST; 23h ago
Main PID: 2290 (caddy)
Tasks: 12 (limit: 9462)
CGroup: /system.slice/snap.rocketchat-server.rocketchat-caddy.service
└─2290 caddy -conf=/var/snap/rocketchat-server/1384/Caddyfile

Jul 24 12:04:07 ubuntu-chat systemd[1]: Started Service for snap application rocketchat-server.rocketchat-caddy.
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: Activating privacy features… done.
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: http:// myserverdomain:8080
Jul 24 12:04:09 ubuntu-chat rocketchat-server.rocketchat-caddy[2290]: WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with “ulimit -n 8192”.