How to enable h2c in Nginx?
Asked Answered
R

1

11

Is there a way to enable h2c aka HTTP2 cleartext in Nginx 1.9.5 onward?

I've tried using h2 over TLs in https://chronic101.xyz and it works, however I would like to implement h2c on port 80 as well.

Thanks,

chrone

Rotor answered 5/12, 2015 at 16:59 Comment(0)
H
9

It should be as simple as adding http2 in the end of your listen directive.

Example:

server {
    listen 80 http2;

However, keep in mind that most browsers do not support unencrypted HTTP/2, and so will still serve content as HTTP/1.1.

Hanghangar answered 9/5, 2016 at 15:5 Comment(2)
Whoa @Gabriel Hautclocq, thanks it finally works on Nginx 1.10. :DRotor
Worth noting is that nginx does not (as of when I'm writing this message) support running h2c on the same port as http/1.1. I.e. it can't magically switch between the protocols.Orgell

© 2022 - 2024 — McMap. All rights reserved.