> Documentation index: https://jetkvm.com/llms.txt

# Reverse Proxy

> Use JetKVM behind a reverse proxy, such as Caddy or nginx, with your own hostname and certificate.

You can put JetKVM or JetKVM Mini behind a reverse proxy to open it at your own hostname, such as `https://kvm.example.com`, with a trusted certificate.

## How it works

The proxy carries the web interface and the signaling WebSocket at `/webrtc/signaling/client`. Video, keyboard, and mouse use WebRTC, which goes directly from your browser to the device over UDP. Thus:

* The proxy must support WebSockets.
* Your browser must reach the device directly. If the page loads but the video stays on **Connecting**, examine the firewall between your computer and the device.

## Proxy setup

The proxy connects to port 80 of the device. This also works with **HTTPS Mode** on.

**Caddy** sends the `Host` header unchanged by default:

```
kvm.example.com {
    reverse_proxy 192.168.1.50:80
}
```

**nginx** changes the `Host` header unless you set it:

```
location / {
    proxy_pass http://192.168.1.50;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
```

Replace `kvm.example.com` with your hostname and `192.168.1.50` with the IP address of the device.

## JetKVM

No settings on the device are necessary. The device counts wrong passwords by client IP address. Behind a proxy, all users share the proxy's address. After 5 wrong passwords, nobody can log in through the proxy for 15 minutes. Repeated lockouts last up to 1 hour.

## JetKVM Mini

JetKVM Mini examines two headers.

1. Set a password, or add the proxy hostname under **Settings** \> **Access** \> **Other Names for This KVM**. Without a password, other names get `421 Misdirected Request`.
2. Send the browser's `Host` header unchanged, and do not change `Origin`. If not, the signaling WebSocket gets `403 Device UI origin required`.

### OPNsense (Caddy plugin)

If you get `403`, go to **Services** \> **Caddy Web Server** \> **Reverse Proxy** \> **Headers** and add a header:

* **Header**: `header_up`
* **Header Type**: `Host`
* **Header Value**: your hostname

Then select that header in the **Headers** field of the handler for JetKVM Mini, save, and click **Apply**.

### Test the proxy

```
curl -s -o /dev/null -w "%{http_code}\n" \
  -H "Connection: Upgrade" -H "Upgrade: websocket" \
  -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  -H "Origin: https://kvm.example.com" \
  https://kvm.example.com/webrtc/signaling/client
```

| Result | Meaning                                                               |
| ------ | --------------------------------------------------------------------- |
| 401    | Correct. The device has a password.                                   |
| 101    | Correct. The device has no password.                                  |
| 403    | The proxy changes Host.                                               |
| 421    | No password, and the hostname is not in **Other Names for This KVM**. |

## Login cookie

When the proxy connects to port 80, the login cookie has no `Secure` flag, because the device sees an HTTP connection.