2

I install nginx 1.13.10 with a wordpress site and openssl on my virtual machine. I'm trying to test http2 push. Here is my nginx conf file:

pastebin.com/71ziXeRh

   server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  192.168.133.21;
        return 302 https://$server_name$request_uri;
}
        # Load configuration files for the default server block.
    server {
        listen          443 ssl http2;
        server_name     192.168.133.21;
        include         conf.d/self-signed.conf; #ssl config
        ssl on;
        location / {
                root /var/www/wordpress/current;
                index index.php index.html index.htm;
                http2_push /wp-content/themes/twentyseventeen/assets/images/header.jpg;
                http2_push /wp-content/themes/twentyseventeen/style.css?ver=4.7.4;
        }

        error_page 404 /404.html;
            location = /40x.html {
                root /usr/share/nginx/html;
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
                root                    /var/www/wordpress/current;
                try_files               $uri =404;
                fastcgi_pass            127.0.0.1:9000;
                fastcgi_index           index.php;
                fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include                 fastcgi_params;
       }
    }

Restart nginx and no error. But when I debug it with Chrome no resource was pushed demo image

Please tell me if I do something wrong somewhere.

D. Y.
  • 21
  • 3
  • Can you please paste the relevant contents of that file here too? – Tamas Rev Mar 28 '18 at 09:31
  • this is the http2 push part location / { root /var/www/wordpress/current; index index.php index.html index.htm; http2_push /wp-content/themes/twentyseventeen/assets/images/header.jpg; http2_push /wp-content/themes/twentyseventeen/style.css?ver=4.7.4; } – D. Y. Mar 28 '18 at 09:33
  • Can you please edit your question and add this part? If you don't have the privilege for that, just let me know and I'll add it. – Tamas Rev Mar 28 '18 at 09:38
  • please add edit question and add details there – kakabali Mar 28 '18 at 09:38
  • ty guys I edited my question – D. Y. Mar 28 '18 at 09:55

1 Answers1

2

It's a restriction in Chrome. If your SSL/TLS cert is not trusted (as we can see yours is not in the screenshot) it ignores pushed resources. Even if you skip paste the HTTPS error. Similarly resources on such a site cannot be cached.

Add the certificate to your browser's trust store so you get a green padlock and it should start to work.

Similar question (but using Node rather than Nginx) here.

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92