proxy_cache_path temp/proxy_temp/osm levels=1:2 keys_zone=osm:2m
max_size=40g inactive=8w use_temp_path=off;
upstream osm {
server a.tile.openstreetmap.org:80;
server b.tile.openstreetmap.org:80;
server c.tile.openstreetmap.org:80;
}
server {
listen 81;
keepalive_timeout 180s;
resolver 1.1.1.1;
access_log off;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 24 4k;
proxy_busy_buffers_size 16k;
proxy_max_temp_file_size 64m;
proxy_temp_file_write_size 32k;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_cache_valid 1d;
proxy_cache_revalidate on;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_cache_lock_timeout 15s;
proxy_socket_keepalive on;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_next_upstream_timeout 5;
proxy_next_upstream_tries 3;
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
add_header X-Cache-Status $upstream_cache_status;
proxy_ignore_headers Expires Cache-Control;
location = /favicon.ico { empty_gif; }
# https://a.tile.openstreetmap.org/15/20906/10576.png
location /osm/ {
proxy_cache osm;
proxy_set_header Host a.tile.openstreetmap.org;
proxy_cache_key "$request_uri";
proxy_pass http://osm/;
}
}