Search code examples
httpnginxpassengerhttp2ruby-on-rails-5.2

How to update a Ruby on Rails website form http 1 to http 2


Currently using Rails 5.2 and Ruby 2.3 with the server: Nginx with passenger

please tell the changes that are required to update the website from HTTP version 1 to HTTP 2.

Virtual Host :

 server {
    listen 80;
    listen [::]:80 ipv6only=on;

server_name ec2-34-xxx-xx-xx.us-west-2.compute.amazonaws.com;

# Tell Nginx and Passenger where your app's 'public' directory is
root /home/ec2-xxxx/apps/xxxxxxxxxx/public;

# Turn on Passenger
rails_env    production;
passenger_enabled on;
passenger_ruby /home/ec2-xxx/.rvm/gems/ruby-2.3.8@5.0.2/wrappers/ruby;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   html;
    }
location ~ /.well-known {
            allow all;
    }

}

Thanks in advance


Solution

  • You can enable HTTP/2 in your Nginx config assuming you are on a relatively new version of Nginx.

    However all browsers only support HTTP/2 over HTTPS. As you are only listening on port 80, I presume you are only set up for HTTP, so the first thing you need to do is setup HTTPS on your website.

    After that, you just need below config (again assuming on a recent version of Nginx), to listen using protocol http2 on port 443:

    listen 443 ssl http2; 
    listen [::]:443 ssl http2 ipv6only=on;