tjo.space/nginx.conf

56 lines
1.7 KiB
Nginx Configuration File
Raw Normal View History

2024-02-06 12:41:32 +00:00
proxy_cache_path /var/run/nginx-cache/jscache levels=1:2 keys_zone=jscache:100m inactive=30d use_temp_path=off max_size=100m;
2024-01-01 22:53:34 +00:00
server {
listen 80 default_server;
server_name _;
resolver 9.9.9.9 1.1.1.1 8.8.8.8;
2024-01-01 22:53:34 +00:00
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
2024-01-01 23:10:59 +00:00
location /.well-known/ {
root /usr/share/nginx/html;
2024-01-01 22:53:34 +00:00
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;
}
2024-01-01 22:53:34 +00:00
# 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;
}
}