01 http { 02 03 log_format http2 '$time_iso8601 $msec $status $connection $http2 "$request"'; 04 05 server { 06 07 listen 443 ssl http2; # TLS and HTTP/2 08 09 http2_idle_timeout 3m; 10 http2_max_requests 1000; 11 12 access_log /usr/local/var/log/nginx/http2.log http2; 13 14 ssl_certificate /test.crt; 15 ssl_certificate_key /test.key; 16 17 root /var/www/html; 18 19 # Required for server push: 20 location /css/ { 21 expires 3h; 22 } 23 24 location /js/ { 25 expires 3h; 26 } 27 28 location /index-2.html { 29 expires 3h; 30 } 31 32 # Example for server push 33 # Call: GET / 34 location /index.html { 35 # These files are sent by push, 36 # when the client calls /index.html: 37 http2_push /css/styles.css; 38 http2_push /js/scripts.js; 39 # expected next navigation destination: 40 http2_push /index-2.html; 41 } 42 43 # Example of Nginx as proxy with http2_push_preload. 44 # The (simulated) application server is below. 45 # Call: GET /applicationserver/ 46 location /applicationserver/ { 47 proxy_pass http://localhost:1025/; 48 # Process link header with rel=preload: 49 http2_push_preload on; 50 } 51 } 52 53 # Simulation application server: 54 server { 55 list 1025; 56 root /var/www/html; 57 58 location ~ .html$ { 59 # Hints for http2_push_preload: 60 add_header link "; rel=preload; as=style"; 61 add_header link "; rel=preload; as=script"; 62 } 63 } 64 }