# Panel HTTPS and domain

URL: https://docs.vaultpanel.net/getting-started/panel-https-and-domain

> How the panel serves HTTPS on its own port with a pinned self-signed certificate, and how to move it to a domain with a trusted certificate.

A new panel serves HTTPS on its own port from the first start, with a self-signed certificate the installer made for the server. Passwords, the setup token and session cookies never cross the network in clear. For a certificate browsers trust, add a domain on top.

## HTTPS on the panel's port

The self-signed certificate is the same approach Cockpit, Webmin and Proxmox use. Browsers warn about it once; the installer prints its SHA-256 fingerprint so you can check the certificate is yours, and `sudo vaultpanel https` shows it again.

- **Adding servers works without a domain.** The **Add server** command carries the certificate's public key pin (`curl --pinnedpubkey … -k` and `--panel-pin`). The agent installer checks it, saves the certificate as `/etc/vaultpanel-agent/panel-ca.pem`, and the agent trusts exactly that certificate. A different certificate, such as one from someone in the middle, is refused.
- **Plain HTTP stays on loopback.** Port `8091` (`VAULTPANEL_LOOPBACK_PORT`) answers plain HTTP on `127.0.0.1` only, for the agent on this server, the panel domain's NGINX and the `vaultpanel` command. It never leaves the machine.
- **No HSTS on an IP address**, so people can always accept the self-signed certificate. A panel domain with a trusted certificate gets HSTS.

The certificate lives in `/etc/vaultpanel/tls/` and is valid for 10 years. It names `localhost`, the server's host name and addresses, and the host of the panel's address.

### Manage it with `vaultpanel https`

| Command | What it does |
| --- | --- |
| `vaultpanel https` | Whether HTTPS is on, the certificate's names, expiry, SHA-256 fingerprint and agent pin. Run it with `sudo` to read the certificate. |
| `sudo vaultpanel https on` | Turns HTTPS on for a panel installed with plain HTTP (before it was the default). It prints the command to run on each other server, so their agents move to HTTPS. |
| `sudo vaultpanel https renew` | A new certificate with this server's current names and addresses (for example after its IP address changed), made with the same key so the pin stays the same. Run the printed command on each other server so its agent gets the new certificate. |
| `sudo vaultpanel https off` | Back to plain HTTP. Not recommended. |

Turning HTTPS on also moves a panel domain added earlier to the loopback port, so it keeps working.

## Put the panel on a domain

Give the panel a domain such as `cp.example.com` with a Let's Encrypt certificate. NGINX on the panel's own server answers for the domain and passes requests to the panel's loopback port.

### Point the domain at the server

Add a DNS `A` record for the domain pointing at the server's public IP address, and make sure ports 80 and 443 are open. If NGINX or Certbot is missing, install the web stack from **This server**'s **Websites** tab first.

### Add the domain

Open **System > Panel Domain**. Under **Domain**, type the domain and click **Add domain**. **Panel port** is already filled in: the panel's loopback port (`8091`), or `8090` on a plain-HTTP panel.

### Get a certificate

Under **SSL certificate**, enter the **Email for Let’s Encrypt**. Keep **Redirect HTTP to HTTPS** and **Check the domain first** ticked.

Tick **Start with a test certificate** and click **Get a test certificate** to try the setup first: failed real requests count against Let's Encrypt's limits. When it works, click **Get the trusted certificate**. Or leave it unticked and click **Get certificate** straight away. **Renew now** renews a trusted certificate by hand; Certbot renews it automatically.

### Use the domain as the panel's address

Under **Panel address**, click **Use https://cp.example.com**. Agent install commands, password reset links and deploy webhooks then use the domain.

Sign in at `https://cp.example.com`. The `https://SERVER_IP:8090` address keeps working, so a DNS or certificate mistake never locks you out. The domain and the server address each keep their own sign-in.

Once the domain works, you can close port 8090 to the outside in the firewall. Agents already connected keep the address they were installed with; new install commands use the domain.

### From the command line instead

`vaultpanel url` sets the panel's address from the server:

```bash
sudo vaultpanel url https://cp.example.com
```

With an `https://` address it also makes sign-in cookies HTTPS-only for every address, so the plain HTTP address stops letting you sign in, and agents on other servers must reach the panel over HTTPS from then on. When the address uses the panel's own port and the certificate does not name its host yet, the command tells you to run `sudo vaultpanel https renew`.

> **Note:**
The domain set up under **System > Panel Domain** is managed only there. It does not appear among your websites, domains and certificates.
