server {
    listen 80;
    return 301 https://$host$request_uri;
}

upstream zulipbot {
    server localhost:8080;
    keepalive 10000;
}

server {
    listen 443;
    server_name zulip.org;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/zulip.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/zulip.org/privkey.pem;

    location /dist/ {
        autoindex on;
        alias /home/zulip/dist/;
    }

    location /zulipbot/ {
        rewrite /zulipbot(.*)/ /$1  break;
        proxy_pass http://zulipbot;
        proxy_set_header X-Real-IP       $remote_addr;
    }

    location / {
        rewrite ^/ https://zulipchat.com permanent;
    }
}
