Q: http2 and http1 virtual hosts both works via HTTP/2 - bug of feature?

Reinis Rozitis r at roze.lv
Fri May 26 11:04:41 UTC 2023

> Observed nginx's version 1.22.1 questionable behaviour with two virtual hosts, one with H2 - enabled, second without http2 support.
> Both on the same IP and port, with different domain names/server names.
> Is it a bug, feature, my misconfiguration or just not needed by anyone?

The short answer is - yes it is supposed to be like that and you would need either to use different ports or different ips for the virtual hosts.

If I'm not wrong the longer answer is that nginx groups all the capabilities for ip:port when listening on it and since the http2 selection happens at TLS handshake but the virtual server selection happens later at SNI it's problematic to switch it off at that phase.

There have been couple similar requests/questions in past (mainly for specific cipher configuration per virtual server) but out of interest - what is the reason/use case for disabling http2 for a particular virtualhost but leaving it for others?


More information about the nginx mailing list