Skip to content

Proxying via nginx on host machine

Nick Sweeting edited this page Jun 29, 2017 · 4 revisions

To proxy connections to the docker-zulip container from nginx running on a host machine, you'll want to add an nginx site with the following configuration:

/etc/nginx/sites-enabled/zulip.yourdomain.com.conf

server {
    listen 80;
    server_name zulip.yourdomain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name zulip.yourdomain.com;

    ssl_certificate     /etc/letsencrypt/live/zulip.yourdomain.com/fullchain.pem;  # generate this with `apt install letsencrypt; letsencrypt certonly zulip.yourdomain.com`
    ssl_certificate_key /etc/letsencrypt/live/zulip.yourdomain.com/privkey.pem;

    port_in_redirect off;
    proxy_buffering off;
    proxy_http_version 1.1;     # Properly proxy websocket connections
    proxy_read_timeout 300s;    # terminate websockets afer 5min of inactivity
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";


    location / {
            proxy_pass  https://127.0.0.1:8089;    # Port that docker-zulip is listening on
    }
}

Then make sure you have these settings in your docker-compose.yml:

 ...
 zulip:
    ports:
      - "8088:80"
      - "8089:443"
    environment:
      ...
      SETTING_EXTERNAL_HOST: "zulip.yourdomain.com"
      SETTING_ALLOWED_HOSTS: "['zulip.yourdomain.com', '127.0.0.1']"
Clone this wiki locally