# Best practices

URL: https://docs.vaultpanel.net/best-practices

> Recommendations for running VaultPanel in production, from panel backups and HTTPS to access control, server hardening and monitoring.

VaultPanel is secure by default: the panel runs as an unprivileged user, serves HTTPS from the first start, and every change is a signed, audited job. The recommendations on this page close the remaining gaps that depend on how you run it. Each one links to the guide that explains it.

## Protect the panel itself

### Keep the panel's backups off the server

`vaultpanel-backup.timer` backs up the panel every day to `/var/backups/vaultpanel-panel`, but a backup on the same disk does not help when the server is gone. Copy each backup somewhere only you can read, and encrypt it when it goes to someone else's storage.

Set both in `/opt/vaultpanel/.env`; the next backup uses them:

| Setting | What to set |
| --- | --- |
| `VAULTPANEL_BACKUP_PASSPHRASE_FILE` | A file holding a passphrase. Backups are then encrypted (AES-256, PBKDF2) as `.tar.gz.enc`. |
| `VAULTPANEL_BACKUP_UPLOAD` | A command run after each backup with the file as `$1`, such as `rclone copy "$1" remote:vaultpanel`. |

Keep the passphrase somewhere other than the server, and practice a restore on a new server with `sudo vaultpanel restore <file>` before you need it. See [Backing up the panel](https://docs.vaultpanel.net/getting-started/backing-up-the-panel).

### Keep the secret key safe

`VAULTPANEL_SECRET_KEY` in `/opt/vaultpanel/.env` decrypts two-factor secrets, the agent signing key and every stored password. Without it, a database backup cannot be used. Panel backups include it, so treat backup files like `.env` itself: root only, encrypted when they leave the server.

### Give the panel a domain, then close port 8090

The panel's own certificate is self-signed. For a certificate browsers trust, put the panel on a domain under **System > Panel Domain** and click **Use https://…** under **Panel address**, so agent install commands, password reset links and deploy webhooks use it.

Once you can sign in on the domain, close port 8090 to the outside in the firewall. The domain is then the only public way in, and it is served with a trusted certificate and HSTS. See [Panel HTTPS and domain](https://docs.vaultpanel.net/getting-started/panel-https-and-domain).

> **Tip:**
Check the domain works before closing the port. `https://SERVER_IP:8090` stays available until you do, so a DNS or certificate mistake never locks you out.

### Keep the panel and agents updated

`sudo vaultpanel update` backs the panel up, installs the newest `vaultpanel` package and updates the database; `sudo vaultpanel rollback` reverses the last update. `sudo apt upgrade` updates VaultPanel with the system's other packages.

When the panel has a newer agent than a server, the server's page shows **Update agent**, and a bulk action can update many servers at once. Operations added in newer agents are refused with `AGENT_OUTDATED` until the server's agent is updated. See [Updating](https://docs.vaultpanel.net/getting-started/updating) and [Server groups](https://docs.vaultpanel.net/guides/servers/server-groups).

## Control who can do what

### Require two-factor sign-in

Turn on two-factor sign-in for your own account under **Account**, and store the 10 recovery codes outside the panel. Then, under **Security > Authentication**, require it for **Owners and admins** or for **Everyone**. Accounts the policy covers can only set it up or sign out until they do. See [Sign-in and two-factor](https://docs.vaultpanel.net/guides/security/sign-in-and-two-factor).

### Give each person the smallest role that works

Permissions are checked in the service layer and denials are audited. People can only grant roles at or below their own. Give each person the built-in role that matches their work rather than making everyone an admin, and deactivate accounts that are no longer needed: that also ends their sessions and stops their API tokens. See [Users and roles](https://docs.vaultpanel.net/guides/security/users-and-roles).

### Scope API tokens narrowly and let them expire

An API token acts as the person who made it, narrowed to the scopes it was given. Give scripts only the scopes they need (for example `deploy` for a CI pipeline instead of `full`), set an expiry, and revoke tokens you no longer use. A token is shown once and only its SHA-256 is stored. See [API tokens](https://docs.vaultpanel.net/api-reference/api-tokens).

### Limit panel access by address

When your team works from known addresses, turn on **Panel access by address** under **Security > Authentication**. Everyone else gets a page saying their address is not accepted, and signing in and the browser terminal are refused. With **Staff only**, hosting customers still sign in from anywhere. Agents, push-to-deploy hooks, billing systems and plugins are never blocked.

Behind a reverse proxy or Cloudflare, set `VAULTPANEL_TRUST_PROXY` so the panel sees people's real addresses. See [Panel access](https://docs.vaultpanel.net/guides/security/panel-access).

### Review the audit log

Every change, denial and sign-in is recorded with who, what, the result, the IP address and the request id, and the database refuses updates and deletes of entries. Review it after incidents and when people leave. See [Audit log](https://docs.vaultpanel.net/guides/security/audit-log).

## Harden every server

Each server's **Security** tab and the **Security Overview** score the firewall, root sign-in, SSH passwords, Fail2ban, automatic updates and waiting updates. Aim to have every check pass:

| Area | Recommendation | Guide |
| --- | --- | --- |
| Firewall | Turn UFW on. VaultPanel keeps SSH and the panel's port open for you and refuses rules that would lock you out. | [Firewall](https://docs.vaultpanel.net/guides/security/firewall) |
| SSH | Add your public key, check you can sign in with it, then turn off password sign-in and set root sign-in to keys only. | [SSH](https://docs.vaultpanel.net/guides/security/ssh) |
| Brute force | Install Fail2ban, turn on **Protect SSH** and add your own address to the addresses that are never blocked. | [Fail2ban and updates](https://docs.vaultpanel.net/guides/security/fail2ban-and-updates) |
| Updates | Turn on daily automatic security updates, and install waiting ones from the panel. | [Fail2ban and updates](https://docs.vaultpanel.net/guides/security/fail2ban-and-updates) |

> **Warning:**
Docker publishes container ports itself, bypassing UFW. Keep container ports on **This server only** and give them a domain through a reverse-proxy website instead of opening a public port. See [Containers](https://docs.vaultpanel.net/guides/applications/containers).

## Back up what you host

Panel backups do not include websites, apps or databases; those have their own backups under **Backups**.

- **Schedule backups** for every website, app and database, with a "keep" count that fits your disk.
- **Store them off the server.** Add an S3-compatible bucket (Amazon S3, Backblaze B2, Wasabi, Cloudflare R2, MinIO) or another server over SFTP under **Backups > Storage**. Copies are encrypted before they leave the server; download each storage's backup key (**Key**) and keep it somewhere other than the panel server, or the copies cannot be read if the panel is lost. Still use a private bucket or a backup server only you can sign in to.
- **Test restores.** A restore takes a safety backup of the current state first, so trying one is safe.

See [Backups](https://docs.vaultpanel.net/guides/backups-and-automation/backups) and [Backup storage](https://docs.vaultpanel.net/guides/backups-and-automation/backup-storage).

## Know when something breaks

- **Alerts**: the default rules include **Server self-check failed** and **Website down**. Send alerts by email from **System > Panel Email** and to Slack, Discord or your own endpoint with [webhooks](https://docs.vaultpanel.net/guides/backups-and-automation/webhooks). See [Monitoring and alerts](https://docs.vaultpanel.net/guides/servers/monitoring-and-alerts).
- **Uptime**: the panel checks every website the way visitors reach it, including the certificate it serves. Leave monitoring on for production sites. See [Uptime monitoring](https://docs.vaultpanel.net/guides/websites/uptime-monitoring).
- **Self-check**: every 5 minutes each agent checks what the panel's features need from its server (`nginx -t`, Certbot's timer, the clock, failed units) and shows the command that fixes a failure. See [Server self-check](https://docs.vaultpanel.net/guides/servers/self-check).

## Keep outgoing requests inside the public internet

Webhooks, plugin manifests and plugin events never reach the panel's own machine, link-local or cloud metadata addresses. On new installs they also refuse private networks (10.x, 172.16-31.x, 192.168.x, 100.64.x, fc00::/7), because `VAULTPANEL_WEBHOOK_ALLOW_PRIVATE` is `false`. Panels installed before this default changed keep `true`.

Leave it off unless a webhook must reach a service on your private network, and leave `VAULTPANEL_PLUGIN_ALLOW_LOCAL` off unless you develop plugins on the panel's own server. See [Webhooks](https://docs.vaultpanel.net/guides/backups-and-automation/webhooks) and [Plugins](https://docs.vaultpanel.net/developers/plugins).
