-
-
Save cbricart/293bdbfedbb2bd3134baeb5632ea3b3c to your computer and use it in GitHub Desktop.
OSM Tile-Cache Nginx Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Nginx >= 1.9.15 - 1.10.1 recommended | |
# | |
proxy_cache_path /var/www/tilecache/osm | |
levels=1:2 inactive=7d | |
keys_zone=tilecache:64m | |
max_size=500M; | |
upstream osm_tiles { | |
server a.tile.openstreetmap.org; | |
server b.tile.openstreetmap.org; | |
server c.tile.openstreetmap.org; | |
keepalive 16; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name tiles.COMMUNITY.freifunk.net | |
~^tiles\d+\.COMMUNITY\.freifunk\.net$; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name tiles.COMMUNITY.freifunk.net | |
~^tiles\d+\.COMMUNITY\.freifunk\.net$; | |
add_header Strict-Transport-Security "max-age=15768000" always; | |
ssl_certificate /path/to/WILDCARD.pem; | |
ssl_certificate_key /path/to/WILDCARD.key; | |
access_log /var/www/tilecache/logs/access.log; | |
error_log /var/www/tilecache/logs/error.log; | |
root /var/www/tilecache/html; | |
location / { | |
try_files $uri @osm; | |
} | |
location @osm { | |
proxy_pass http://osm_tiles; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
proxy_set_header Accept-Encoding ""; | |
proxy_set_header User-Agent "Mozilla/5.0 (compatible; OSMTileCache/1.0; +mailto:contact@site.freifunk.net; +https://map.COMMUNITY.freifunk.net/)"; | |
proxy_set_header Host tile.openstreetmap.org; | |
proxy_temp_path /var/www/tilecache/temp; | |
proxy_cache tilecache; | |
proxy_store off; | |
proxy_cache_key $uri$is_args$args; | |
proxy_ignore_headers Expires Cache-Control; | |
proxy_cache_valid 200 301 302 7d; | |
proxy_cache_valid 404 1m; | |
proxy_cache_valid any 1m; | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_404; | |
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_503 http_504 http_403 http_404; | |
proxy_hide_header Via; | |
proxy_hide_header X-Cache; | |
proxy_hide_header X-Cache-Lookup; | |
expires 7d; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment