UI review, stage 2: nginx security headers, gzip, cache; npm ci; no v-html

default.conf.template: X-Content-Type-Options, X-Frame-Options,
Referrer-Policy, CSP, gzip, immutable cache for /assets/, no-cache for
index.html and config.json, server_tokens off, drop proxy_pass_header.
Dockerfile uses npm ci, .dockerignore added (nginx stays root: the image
entrypoint and port 80 need it). Status badge is a component instead of
v-html.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-07 13:07:16 +03:00
1 parent b78de98f26
commit 600119cdd1
6 files changed
+76 -32

No files matched your search

+35 -2
View File
@@ -1,21 +1,54 @@
server {
listen 80;
server_name localhost;
server_tokens off;
root /usr/share/nginx/html;
index index.html;
# Security headers. add_header in a location replaces the ones inherited from the server block,
# so the /assets/ location below repeats them. CSP: the bundle is served from this origin only;
# style-src 'unsafe-inline' is needed by Bootstrap and Chart.js (inline style attributes);
# connect-src 'self' means config.json must point to proxied paths (the defaults /api/v1 and /profiles-api).
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/javascript application/javascript application/json image/svg+xml;
location / {
try_files $uri $uri/ /index.html;
}
# Hashed build files never change under the same name
location /assets/ {
try_files $uri =404;
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
}
# The entry page and the runtime configuration must be revalidated after an update
# (expires -1 sends "Cache-Control: no-cache" and keeps the server-level headers)
location = /index.html {
expires -1;
}
location = /config.json {
expires -1;
}
# Модуль 1: Мониторинг (Flask, порт 5001)
location /api/ {
proxy_pass http://${OVP_API_HOST}:${OVP_API_PORT};
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_pass_header Authorization;
}
# Модуль 2: Управление профилями (FastAPI, порт 8000)
@@ -34,4 +67,4 @@ server {
location = /50x.html {
root /usr/share/nginx/html;
}
}
}