HTTP/2 in Nginx

  1. You don’t need to manually add this:

     server {
       listen 80;
       location / {
         return 301 https://$host$request_uri;
       }
     }
    
  2. The ssl certificate path is automatically generated and added by Virtualmin when you request a certificate for a virtual server.

  3. Revert the changes you made to this line listen 443 ssl http2 default_server; back to the default generated by Virtualmin and just add http2 to it.

  4. Restart Nginx.


TLDR: To enable http2, you don’t have to change anything in the default Virtualmin-generated virtual host file except add http2 to this line:

listen xxx.xxx.xxx.xx ssl;

So it’ll look like this:

listen xxx.xxx.xxx.xx ssl http2;

And then simply restart Nginx.

2 Likes