This guide details how to configure Nginx as a reverse proxy for the OpenVPN Monitor & Profiler application. Nginx is **required** in production to serve the frontend and route API requests to the appropriate backend services.
## Architecture Recap
-**Frontend (`APP_UI`)**: Static files (HTML, JS, CSS) served from `/var/www/ovpmon` (or similar).
-**Core API (`APP_CORE`)**: Python/Flask service running on **127.0.0.1:5001**.
-**Profiler API (`APP_PROFILER`)**: Python/FastAPI service running on **127.0.0.1:8000**.
## 1. Alpine Linux Setup
### Installation
```bash
apk add nginx
rc-update add nginx default
```
### Configuration
Create a new configuration file (e.g., `/etc/nginx/http.d/ovpmon.conf`).
```nginx
server{
listen80;
server_nameyour-server-domain.com;# Replace with your IP or Domain
## 4. Security headers and CSP (site written by `install.sh`)
The site that `install.sh` / `update.sh` write (`deploy/native/nginx/ovpmon.conf.template`, first line has the marker "managed by ovpmon") sends `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `Cache-Control: no-store` and a Content-Security-Policy:
The headers are declared on the `server` level only: an `add_header` inside a `location` would drop all of them. `style-src 'unsafe-inline'` is needed by Bootstrap and Chart.js.
The default `connect-src` allows the page origin only. If `config.json` points the UI to an API on another host, add its origin:
```bash
deploy/native/update.sh --csp-connect-extra "https://api.example.com http://10.0.0.5:5001" # several origins: separated by spaces
deploy/native/update.sh --csp-connect-extra "" # remove them
```
`install.sh` accepts the same option. The value is kept in `/etc/ovpmon/deploy.state` (`OVPMON_CSP_CONNECT_EXTRA`) and applied again by every update. Only `https://host[:port]` and `http://host[:port]` are accepted (the value ends up in a response header). An existing site without the marker line is not changed by `update.sh`: add the CSP there by hand. The API on the other origin must also allow this UI origin (`OVPMON_CORS_ORIGINS`).