qnote/web/nginx.conf
2025-04-22 21:30:21 +03:00

48 lines
1.5 KiB
Nginx Configuration File

server {
listen 80;
root /usr/share/nginx/html;
# TLS termination should be handled by a reverse proxy (e.g. Traefik)
# General security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# Block access to dotfiles
location ~ /\.(?!well-known) {
deny all;
access_log off;
log_not_found off;
}
# Enable gzip compression for all assets
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
location /api {
proxy_pass http://qnote-server:8080; # Internal Docker DNS
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 7d;
add_header Cache-Control "public, no-transform";
}
}
# Route 404 errors to front page
error_page 404 /;
}