Welcome! Log In Create A New Profile

Advanced

How to close client HTTP/2 connections?

November 23, 2018 03:49AM
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
Subject Author Posted

How to close client HTTP/2 connections?

filex November 23, 2018 03:49AM

Re: How to close client HTTP/2 connections?

Olaf van der Spek November 23, 2018 09:11AM

Re: How to close client HTTP/2 connections?

filex November 23, 2018 09:32AM

Re: How to close client HTTP/2 connections?

Olaf van der Spek November 23, 2018 09:49AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 248
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready