Hello,
we use NGINX as http/2 and TLS offloader. Therefore it is responsible for connection handling. (Most of the requests are proxy_pass'ed to upstream servers. However, some few requests are served from local files.)
Now, I would like to close the client connection under certain circumstances. That could be the presence of a certain upstream response header or status code.
I have tried
more_set_headers -s '502 503' 'Connection: close';
This works for HTTP/1 connections.
However, this Connection header seems to be forbidden in h2. Triggering the header with curl (-v --http2) yields an error:
http2 error: Invalid HTTP header field was received: frame type: 1, stream: 1, name: [connection], value: [close]
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
Ok, the connection is closed :) But quite elegantly.
And I forgot to mention that I would like to serve an error message, like a "sorry…" HTML. (Therefore I couldn't use the 444 status.)
How could I do this for h2: Serve a last page and then say GOWAY?
Best regards,
Felix