Nginx crashes with 'host not found in upstream "backend"' after following reverse proxy instructions


I have been trying to set up an Nginx reverse proxy for SSL for a while now, but I keep getting problems. This is the most recent one. Following the setup instructions in the official documentation leads me to a dead end where I just cannot get it running, and I have no idea where I’ve gone wrong. Our server is behind Cloudflare, which I’ve heard can greatly complicate this.

I have changed the site’s name to mysite.example, as it’s run on my friend’s server, who doesn’t want me spreading the domain until the chat is fully set up. Our Cloudflare SSL settings are on ‘flexible’, and I was also wondering whether or not I should just turn them off completely.

Server Setup Information

  • Version of Rocket.Chat Server: 3.12.1
  • Operating System: Ubuntu Xenial
  • Deployment Method: Tar
  • Number of Running Instances: 1
  • NodeJS Version: 12.18.4
  • MongoDB Version: 4.0.23
  • Proxy: Nginx
  • Firewalls involved: Cloudflare, UFW

Any additional Information


upstream backend {

HTTPS Server

server {
listen 443;
server_name mysite.example www.mysite.example;

# You can increase the limit if your need to.
client_max_body_size 200M;

error_log /var/log/nginx/rocketchat.access.log;

ssl on;
ssl_certificate /etc/letsencrypt/live/mysite.example/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.example/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE

location / {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Nginx-Proxy true;

    proxy_redirect off;


service file

Description=The Rocket.Chat server nginx.service mongod.service
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=https://mysite.example PORT=2052