Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How to Enable HTTP/2.0 in NGINX

    How to Enable HTTP/2.0 in NGINX

    By RahulDecember 7, 20153 Mins Read

    HTTP/2 (HTTP/2.0) is the major upgrade over HTTP/1 protocol. HTTP/2 protocol is based on SPDY (generally known as speedy). Some of the key improvements of HTTP/2 are:

    Advertisement
    • Server push: Server will pro-actively sent components to clients, So clients doesn’t need to wait for sending requests to server.
    • Multiplexing: Reducing number of active connection by bundling multiple HTTP requests from client and sent to server.
    • Encryption: efficiently use to encryption with TLS protocol in HTTP/2 over HTTP/1.1.
    • HTTP header compression: Compressed headers will reduce the overhead of additional requests to web server.

    Enable HTTP2.0 in NGINX

    This article will help you to enable HTTP/2.0 in NGINX web server on CentOS / Red Hat/ Debian and Ubuntu systems.

    Install NGINX

    HTTP/2 protocol supported over nginx version >=1.9.5. So make sure that your nginx version is supporting HTTP/2 protocol or not. If you have not installed Nginx or older version use one of following method to install or upgrade it based on your operating system.

    For CentOS / RedHat Users

    First create a yum repository configuration file /etc/yum.repos.d/nginx.repo and add the following content in that file.

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    

    and use the following command to install it.

    # yum install nginx
    

    For Ubuntu Users

    Use the following commands to add PPA for installing latest Nginx version on your Ubuntu system. This PPA has nginx version which supports HTTP/2 protocol.

    $ echo "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" >> /etc/apt/sources.list
    $ echo "deb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx"  >> /etc/apt/sources.list
    

    and use the following commands to install it.

    $ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
    $ sudo apt-get update
    $ sudo apt-get install nginx
    

    For Debian Users

    Use the following commands to add PPA for installing latest Nginx version on your Debian system. This PPA has nginx version which supports HTTP/2 protocol.

    $ echo "deb http://nginx.org/packages/mainline/debian/ `lsb_release -cs` nginx" >> /etc/apt/sources.list
    $ echo "deb-src http://nginx.org/packages/mainline/debian/ `lsb_release -cs` nginx"  >> /etc/apt/sources.list
    

    and use the following commands to install it.

    $ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
    $ sudo apt-get update
    $ sudo apt-get install nginx
    

    Verify NGINX Version

    After successful installation of Nginx version on your system, make sure you have Nginx >= 1.9.5. Earlier version does not supports HTTP/2 protocol.

    # nginx -v
    
    nginx version: nginx/1.9.7
    

    Enable HTTP/2 in NGINX

    HTTP/2 protocol requires SSL/TLS virtual hosts. You can’t use HTTP/2 protocol without SSL/TLS enabled websites. Now edit your website VirtualHost and add http2 keyword in listen section.

    server {
      listen        443 ssl http2;
      server_name   exmple.com;
    
      location / {
          root   /var/www/example.com;
          index  index.html index.htm;
      }
    
      ssl on;
      ssl_certificate  /etc/nginx/ssl/example.com.crt;
      ssl_certificate_key   /etc/nginx/ssl/example.com.key;
    
    }
    

    Verify HTTP/2.0

    Use following online tool for testing HTTP/2 support on your website.

    https://tools.keycdn.com/http2-test

    HTTP/2.0 HTTP2
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Implementing a Linux Server Security Audit: Best Practices and Tools

    15 Practical Examples of dd Command in Linux

    Iptables: Common Firewall Rules and Commands

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.