map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    listen 443 ssl http2;
    server_name ott.secretbee.buzz;

    ssl_certificate /etc/letsencrypt/live/ott.secretbee.buzz/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ott.secretbee.buzz/privkey.pem;
    #deny all;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_pass_header Set-Cookie;

        # optional, but recommended if you have problem with clients disconnecting and reconnecting frequently
        proxy_connect_timeout 7d;
        proxy_read_timeout 7d;
        proxy_send_timeout 7d;

        proxy_socket_keepalive on;
    }
}