{"id":162,"date":"2016-11-20T21:03:58","date_gmt":"2016-11-20T13:03:58","guid":{"rendered":"https:\/\/blog.freesilo.com\/?p=162"},"modified":"2016-11-20T21:03:58","modified_gmt":"2016-11-20T13:03:58","slug":"enable-http2-on-nginx","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=162","title":{"rendered":"Enable HTTP\/2 on Nginx"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-163\" src=\"https:\/\/blog.freesilo.com\/wp-content\/uploads\/2016\/11\/http2-nginx-crop-816x304.jpg\" alt=\"http2-nginx-crop-816x304\" width=\"816\" height=\"304\" srcset=\"https:\/\/freesilo.com\/wp-content\/uploads\/2016\/11\/http2-nginx-crop-816x304.jpg 816w, https:\/\/freesilo.com\/wp-content\/uploads\/2016\/11\/http2-nginx-crop-816x304-300x112.jpg 300w, https:\/\/freesilo.com\/wp-content\/uploads\/2016\/11\/http2-nginx-crop-816x304-768x286.jpg 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Experimental support for HTTP\/2 became available in Nginx version 1.9.5 (mainline). It is really easy to enable, and I\u2019ll show you how.<span id=\"more-602\"><\/span><\/p>\n<p>First of all: If you\u2019re not running the latest version yet, I recommend that you <a href=\"https:\/\/bjornjohansen.no\/install-latest-version-of-nginx-on-ubuntu\">upgrade Nginx to the latest version<\/a>.<\/p>\n<hr \/>\n<p>If you\u2019re already running SPDY, please note that the SPDY module have been replaced with the HTTP\/2 module in Nginx. Fortunately, to run HTTP\/2 you just need to upgrade to Nginx 1.9.5 or later and replace <code>spdy<\/code> with <code>http2<\/code> on your <code>listen<\/code> directive line.<\/p>\n<hr \/>\n<p>Now, make sure your version of Nginx is compiled with HTTP\/2 support:<\/p>\n<pre><code class=\"language-bash\">$ nginx -V\r\n<\/code><\/pre>\n<p>Make sure you can find <code>--with-http_v2_module<\/code> somewhere in that output. If you don\u2019t, upgrade to a build that supports HTTP\/2 \u2013 like the link I posted above.<\/p>\n<div><\/div>\n<p>Now it is as simple as adding a single word to your Nginx config. Open the server block config for your HTTPS site (all implementations of HTTP\/2 require HTTPS), and change this line:<\/p>\n<pre><code>listen 443 ssl;\r\n<\/code><\/pre>\n<p>to:<\/p>\n<pre><code>listen 443 ssl http2;\r\n<\/code><\/pre>\n<p>and reload your config:<\/p>\n<pre><code class=\"language-bash\">$ service nginx reload\r\n<\/code><\/pre>\n<p>(If you haven\u2019t enabled HTTPS yet, check this post: <a href=\"https:\/\/bjornjohansen.no\/securing-nginx-ssl\">Securing Nginx with HTTPS<\/a>)<\/p>\n<p>Now all HTTP\/2 enabled visitors should get your site delivered over HTTP\/2, while older browsers get regular SSL (really: TLS). <a href=\"http:\/\/caniuse.com\/#feat=http2\">Major browsers supports HTTP\/2 now<\/a>.<\/p>\n<p>The only thing left, is that you probably want to <a href=\"https:\/\/bjornjohansen.no\/redirect-to-https-with-nginx\">route all visitors that comes through standard HTTP on port 80 to your HTTPS port 443<\/a>.<\/p>\n<p>If you haven\u2019t already done so, you are now ready to <a href=\"https:\/\/bjornjohansen.no\/optimizing-https-nginx\">optimize HTTPS on Nginx<\/a>.<\/p>\n<p>FROM\uff1ahttps:\/\/bjornjohansen.no\/enable-http2-on-nginx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Experimental support for HTTP\/2 b&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=162\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-nginx"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":1,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/164"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}