How to enable HTTP/2 support in NGINX
Last updated: 15 Feb 2018
Nginx 1.9.5
and later versions have HTTP/2 support. Most of the default repositories on Ubuntu/Debian and
RHEL/CentOS has versions later than 1.9.5
, so we skip the upgrading part.
Add HTTP/2 Support
We highly recommend you enable HTTPS support for your web site first. Most web browser simply do not support HTTP/2 over plain text. Besides, there are no excuses to not use HTTPS anymore.
HTTP/2 can be enabled on a site-by-site basis. Locate your site's corresponding configuration file, and add http2
to its listen directive.
Overall, your configuration file should look something like this:
server { listen 443 ssl http2; server_name your-awesome-site.com; ... }
Push resources
Nginx has recently committed changes that add HTTP/2 push capabilities. It's not available right now unless you build it from the source, and we don't recommend using it in any production web sites.
This page will be updated with Nginx HTTP/2 push information soon.