server {
    listen                  443 ssl http2;
    listen                  [::]:443 ssl http2;
    server_name             stream.graff.estate;
    root                    /var/www/stream.graff.estate/client/dist;

    # SSL
    ssl_certificate         /etc/letsencrypt/live/stream.graff.estate/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/stream.graff.estate/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/stream.graff.estate/chain.pem;

    # security
    include                 nginxconfig.io/security.conf;

    # logging
    access_log              /var/log/nginx/access.log combined buffer=512k flush=1m;
    error_log               /var/log/nginx/error.log warn;

    # index.html fallback
    location / {
        try_files $uri $uri/ /index.html;
    }

    location /api {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass            http://127.0.0.1:6000;
        proxy_set_header Host $host;
        include               nginxconfig.io/proxy.conf;
    }

    location /socket.io {
        proxy_pass            http://127.0.0.1:6001;
        proxy_set_header Host $host;
        include               nginxconfig.io/proxy.conf;
    }

    # additional config
    include nginxconfig.io/general.conf;
}

# HTTP redirect
server {
    listen      80;
    listen      [::]:80;
    server_name stream.graff.estate;
    include     nginxconfig.io/letsencrypt.conf;

    location / {
        return 301 https://stream.graff.estate$request_uri;
    }
}