upstream example_ws_backend {
    server 127.0.0.1:8081;
    keepalive 32;
}

server {
    listen 80;
    listen [::]:80;
    server_name ws.example.com;
    include /etc/nginx/snippets/acme-challenge.conf;
    location / { return 308 https://ws.example.com$request_uri; }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name ws.example.com;

    include /etc/nginx/snippets/tls-example.conf;
    include /etc/nginx/snippets/security-headers.conf;
    include /etc/nginx/snippets/hsts.conf;

    limit_conn conn_per_ip 20;

    location / {
        proxy_pass http://example_ws_backend;
        include /etc/nginx/snippets/proxy-common.conf;

        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_buffering off;
        proxy_read_timeout 1h;
        proxy_send_timeout 1h;
    }
}
