Skip to content

Instantly share code, notes, and snippets.

@cquest
Last active October 3, 2019 06:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cquest/ef82d82e7700e116b340ca3f77532880 to your computer and use it in GitHub Desktop.
Save cquest/ef82d82e7700e116b340ca3f77532880 to your computer and use it in GitHub Desktop.
Exemple de configuration nginx pour installer un cache de tuiles OSM
# conserver les tuiles dans /var/cache, pendant 24h et au maximum 16Go
proxy_cache_path /var/cache/nginx-tilecache levels=1:2 keys_zone=tilecache:100m inactive=24h max_size=16G;
server {
server_name tilecache.mondomaine.tld a.tilecache.mondomaine.tld b.tilecache.mondomaine.tld c.tilecache.mondomaine.tld;
listen 80;
location / {
proxy_pass http://tilecache.openstreetmap.fr;
proxy_cache tilecache;
proxy_cache_valid 200 302 24h;
proxy_cache_valid 404 1m;
proxy_cache_lock on;
# on ajoute l'IP du client dans la requête vers le upstream
proxy_set_header X-Forwarded-For $remote_addr;
# on indique le status du cache dans la réponse au client
add_header X-Cache-Status $upstream_cache_status;
# si upstream down, on envoie la copie qu'on a en cache
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
}
}
@Cyrille37
Copy link

Merci ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment