template-web-astro/nginx.conf
Florian Bouillon b58740a229
Some checks failed
Build, check & Test / run (push) Failing after 14s
choire: Update NGINX config
2023-10-09 08:12:25 +00:00

75 lines
2.6 KiB
Nginx Configuration File

worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 3000;
listen [::]:3000;
server_name _;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
error_page 404 /404.html;
error_page 500 502 503 504 /500.html;
# Security headers (note: temporarely unvailable "prefetch-src 'self'; ")
add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data: 'self'; font-src 'self'; connect-src 'self'; base-uri 'self';";
add_header X-Frame-Options "DENY";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Referrer-Policy "no-referrer";
add_header Permissions-Policy "geolocation=(), microphone=(), interest-cohort=()";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Download-Options "noopen";
location / {
try_files $uri $uri.html $uri/index.html /$uri /$uri/index.html /index.html;
}
# Plausible script
location /js/script.js {
# Change this if you use a different variant of the script
proxy_pass https://plausible.io/js/script.js;
proxy_set_header Host plausible.io;
# Tiny, negligible performance improvement. Very optional.
proxy_buffering on;
}
# Plausible script
location /api/event {
proxy_pass https://plausible.io/api/event;
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;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webp|webm|htc|woff2|woff)$ {
expires 1y;
access_log off;
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
}
}
}