Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
75 lines
3.2 KiB
Plaintext
75 lines
3.2 KiB
Plaintext
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 is 'self' plus OVP_CSP_CONNECT_EXTRA (origins separated by spaces, empty by default): set it
|
|
# only when config.json points the UI to an API on another origin (the defaults /api/v1 and /profiles-api are
|
|
# proxied below, same origin). The value is validated by the deploy scripts and by the all-in-one entrypoint.
|
|
# One policy ($csp) for both places.
|
|
set $csp "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' ${OVP_CSP_CONNECT_EXTRA}; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'";
|
|
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 $csp 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 $csp 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;
|
|
}
|
|
|
|
# Модуль 2: Управление профилями (FastAPI, порт 8000)
|
|
# Мы проксируем /profiles-api/ на внутренний /api/ внутри FastAPI
|
|
location /profiles-api/ {
|
|
proxy_pass http://${OVP_PROFILER_HOST}:${OVP_PROFILER_PORT}/api/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
# Для корректной работы OpenAPI/Docs за заголовком
|
|
proxy_set_header X-Forwarded-Prefix /profiles-api;
|
|
}
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
}
|