Skip to content

Instantly share code, notes, and snippets.

@davidtgq
Created October 17, 2019 00:47
Show Gist options
  • Save davidtgq/cd5258309724ebf09d8a2f49cbfa9eca to your computer and use it in GitHub Desktop.
Save davidtgq/cd5258309724ebf09d8a2f49cbfa9eca to your computer and use it in GitHub Desktop.
proxy_cache_path /var/www/cache/osm levels=1:2 keys_zone=osm-tiles:100m max_size=50g inactive=7d;
location /osm/ {
access_log /var/log/nginx/tiles_access.log combined;
error_log /var/log/nginx/tiles_error.log info;
expires 7d;
proxy_cache osm-tiles;
proxy_cache_key "$request_uri";
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_lock on; # if race cond, only one request goes to OSM server
proxy_cache_valid 200 302 7d;
proxy_cache_valid 404 1m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://tile.openstreetmap.org/; # don't need [abc] since no browser limitation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment