Published 5 months ago
Published 5 months ago
Naldela Teleyal
Updated 8 months ago
0
Maybe a small asset cache to speed up some transfers, like npm does?
1proxy_cache_path /usr/share/nginx/public-cache levels=1:2 keys_zone=public-cache:30m max_size=192m;
1 location ~* ^.*\.(css|js|jpe?g|gif|png|webp|woff|eot|ttf|svg|ico|css\.map|js\.map)$ { 2 if_modified_since off; 3 proxy_buffering on; 4 5 # use the public cache 6 proxy_cache public-cache; 7 proxy_cache_key $host$request_uri; 8 proxy_cache_min_uses 1; 9 10 # ignore these headers for media 11 proxy_ignore_headers Set-Cookie Cache-Control Expires X-Accel-Expires; 12 13 # cache 200s and also 404s (not ideal but there are a few 404 images for some reason) 14 proxy_cache_valid any 30m; 15 proxy_cache_valid 404 1m; 16 17 # strip this header to avoid If-Modified-Since requests 18 proxy_hide_header Last-Modified; 19 proxy_hide_header Cache-Control; 20 proxy_hide_header Vary; 21 22 proxy_cache_bypass 0; 23 proxy_no_cache 0; 24 25 proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504 http_404; 26 proxy_connect_timeout 5s; 27 proxy_read_timeout 45s; 28 29 expires @30m; 30 31 proxy_set_header Accept-Encoding ''; 32 proxy_set_header Referer $http_referer; 33 proxy_set_header Host $host; 34 proxy_set_header Cookie $http_cookie; 35 proxy_set_header Upgrade $http_upgrade; 36 proxy_set_header Connection $connection_upgrade_keepalive; 37 38 proxy_set_header X-Real-IP $remote_addr; 39 proxy_set_header X-Forwarded-Host $host; 40 proxy_set_header X-Forwarded-Server $host; 41 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 42 43 add_header X-Cache-Status $upstream_cache_status; 44 proxy_pass ....; 45 }
Monster
Updated 8 months ago
0
We are planning to add the feature of customizing nginx configuration files recently, and you can write these configurations directly into it.