server { listen 80 default_server; server_name _; resolver 9.9.9.9 1.1.1.1 8.8.8.8; location / { root /usr/share/nginx/html; index index.html index.htm; } location /.well-known/ { root /usr/share/nginx/html; default_type application/json; add_header Access-Control-Allow-Origin *; } # Plausible Analytics # https://plausible.io/docs/proxy/guides/nginx set $plausible_script_url https://plausible.io/js/script.js; # Change this if you use a different variant of the script set $plausible_event_url https://plausible.io/api/event; location = /js/script.js { proxy_pass $plausible_script_url; proxy_set_header Host plausible.io; # Tiny, negligible performance improvement. Very optional. proxy_buffering on; # Cache the script for 6 hours, as long as plausible.io returns a valid response proxy_cache jscache; proxy_cache_valid 200 6h; proxy_cache_use_stale updating error timeout invalid_header http_500; # Optional. Adds a header to tell if you got a cache hit or miss add_header X-Cache $upstream_cache_status; } location = /api/event { proxy_pass $plausible_event_url; proxy_set_header Host plausible.io; proxy_buffering on; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }