location = /api/asterisk/ws {
    if ($http_sec_websocket_protocol != 'sip') {
        return 403;
    }

    proxy_pass http://127.0.0.1:5039/ws;
    proxy_http_version 1.1;
    proxy_read_timeout 188s;  # twice the default SIP CRLF keep-alive + 8seconds
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
