0

I am able to implement HTTP/2 on my Nginx server which resides within a Docker container. However, I am not able to carry out server push.

These are the configuration files that I have written. /etc/nginx/sites-available/lilstories

server {  
  listen 443 ssl http2 default_server;  
  listen [::]:443 ssl http2 default_server;  
  include snippets/self-signed.conf;  
  include snippets/ssl-params.conf;  
  root /var/www/lilstories;  
  index Joke.html sniper.html;  
  server_name x.x.x.x;  
  location = /Joke.html {  
    http2_push /var/www/lilstories/YNWA.jpg;  
  }  
}  

Developers Tool snapshot

The developers tool does not show Push in the initiator column for the jpg file.No errors show up in the error log. Could anyone point out where I'm going wrong?

HBruijn
  • 77,029
  • 24
  • 135
  • 201

2 Answers2

2

I would guess you are using self-signed certificates based on this config name?

include snippets/self-signed.conf;

If the self-signed certificate is not trusted by the browser (so you get a red padlock that you probably clicked through?) then caching will not be used by Chrome. This includes the Push Cache needed for HTTP/2 Push to work.

Accept the self-signed certificate to your trust store so you get a green padlock and it should work.

This is in addition to HBruijn’s correct comment on the syntax being used wrongly.

Barry Pollard
  • 4,591
  • 15
  • 26
1

The http2_push directive is followed by a URI path, but it looks like you have listed an absolute path on your file system.

Instead of:

http2_push /var/www/lilstories/YNWA.jpg; 

use

http2_push /YNWA.jpg; 
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • Doesn't work, initiator still show index. The nginx version that I run is nginx/1.14.2 .Is it possible that Server Push is not available for this version? I think Server Push is available for the free version too if I am not wrong – user11215077 May 22 '19 at 16:47