user nginx; worker_processes auto; worker_cpu_affinity auto; pid /run/nginx.pid; events { worker_connections 4086; use epoll; multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; keepalive_requests 1000; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_min_length 256; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript application/json application/x-protobuf; proxy_cache_path /var/cache/nginx/ levels=1:2 max_size=10g inactive=60m use_temp_path=off keys_zone=backend_cache:10m; upstream tiles_upstream { server tiles:3000; } server { # listen 80; listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl_certificate /etc/ssl/certs/cert.pem; ssl_certificate_key /etc/ssl/certs/private.pem; server_name localhost martin.maplibre.org maplibre.org cloudflare.com; resolver 127.0.0.1; location / { root /usr/share/nginx/html; try_files $uri /index.html; } location ~ /tiles/(?.*) { proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto "https"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Rewrite-URL $uri; proxy_redirect off; proxy_connect_timeout 5m; proxy_send_timeout 5m; proxy_read_timeout 5m; send_timeout 5m; proxy_cache backend_cache; proxy_cache_lock on; proxy_cache_revalidate on; proxy_cache_valid 200 204 302 1d; proxy_cache_valid 404 1m; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; add_header X-Cache-Status $upstream_cache_status; proxy_pass http://tiles_upstream/$fwd_path$is_args$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } }