Files
OpenVPN-Monitoring-Simple/deploy/native/nginx/ovpmon.conf.template
T

80 lines
3.8 KiB
Plaintext
Raw Normal View History

# managed by ovpmon deploy/native (install.sh / update.sh replace this file only while this marker line is present)
#
# HTTPS site of OpenVPN Monitor & Profiler. Rendered by install.sh / update.sh: they fill in the HTTPS port
# (default 8088), the extra CSP connect-src origins (default none), the UI directory (/var/www/ovpmon) and the certificate and key paths (/etc/ovpmon/tls/ovpmon.crt
# and .key: self-signed by install.sh; replace them with a real certificate under the same names, or edit this
# file and remove the marker line above so that updates leave it alone).
# Installed to the nginx include directory (Alpine /etc/nginx/http.d, Debian/Ubuntu /etc/nginx/conf.d),
# both are included in the http {} block of the distribution nginx.conf. No ssl_session_cache is declared
# here on purpose: a second "shared:SSL" zone with another size would conflict with nginx.conf.
# Reference: DOCS/Deployment/System_Services/Nginx_Configuration.md, APP_UI/default.conf.template
# 5 login attempts per minute per client address (the application has its own lockout as well)
limit_req_zone $binary_remote_addr zone=ovpmon_login:1m rate=5r/m;
server {
listen @HTTPS_PORT@ ssl;
server_name _;
ssl_certificate @TLS_CRT@;
ssl_certificate_key @TLS_KEY@;
ssl_protocols TLSv1.2 TLSv1.3;
server_tokens off;
client_max_body_size 2m;
# Plain HTTP on the TLS port: redirect to HTTPS
error_page 497 =301 https://$host:@HTTPS_PORT@$request_uri;
# Security headers (declared only here: add_header in a location would drop these)
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
add_header Cache-Control "no-store" always;
# 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: same origin plus the optional origins of another API host
# (install.sh / update.sh --csp-connect-extra, state OVPMON_CSP_CONNECT_EXTRA; the value is filled in
# with its own leading space, so there is none before the placeholder). Same policy as APP_UI/default.conf.template.
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'@CSP_CONNECT_EXTRA@; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
root @WEB_ROOT@;
index index.html;
# UI (single-page application)
location / {
try_files $uri $uri/ /index.html;
}
# Login: rate limited
location = /api/auth/login {
limit_req zone=ovpmon_login burst=3 nodelay;
limit_req_status 503;
proxy_pass http://127.0.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Monitoring API (Flask, APP_CORE)
location /api/ {
proxy_pass http://127.0.0.1:5001;
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;
}
# Profiler API (FastAPI, APP_PROFILER): /profiles-api/x is /api/x inside the profiler
location /profiles-api/ {
proxy_pass http://127.0.0.1:8000/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;
proxy_set_header X-Forwarded-Prefix /profiles-api;
proxy_read_timeout 120s;
}
}