Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: Reverse proxy: allow only one client

$
0
0
My use case could be satisfied by something like

- If a client makes an upgrade request
- Check if there is already an established websocket connection upstream
- And if so, return a 503

(I get this would allow multiple clients to make non-websocket requests, that's okay in my case.)

Is this something that njs scripting can tackle? Just learning about that now . . . maybe use the filesystem module to

- set a variable (e.g., num_ws_conns) to 1 when an upgrade connection is established (i.e., first websocket connection upstream)
- on subsequent upgrade requests check num_ws_conns and if greater than 0, 503 the request
- set num_ws_conns to 0 when the websocket request is closed

Just spitballing here . . . would appreciate feedabck if this is a reasonable approach, pointers welcome!

Viewing all articles
Browse latest Browse all 4759

Trending Articles