server {
    listen 80;
    server_name stagingws.spottorg.ru;
    return 301 https://$server_name$request_uri;
}

upstream centrifugo {
    server centrifugo:8000;
}

server {
    listen 443 ssl;
    server_name stagingws.spottorg.ru;

    access_log /var/log/nginx/stagingws.spottorg.ru_access.log json;
    error_log /var/log/nginx/stagingws.spottorg.ru_error.log;

    ssl_certificate /etc/nginx/ssl/spottorg.crt;
    ssl_certificate_key /etc/nginx/ssl/spottorg.key;

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://centrifugo;
    }
    location /socket {
        proxy_buffering off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass http://centrifugo;
    }
    location /connection {
        proxy_buffering off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass http://centrifugo;
    }
}
