> For the complete documentation index, see [llms.txt](https://docs.wizarr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wizarr.dev/getting-started/reverse-proxy.md). Agents can also search and read this documentation through its [MCP server](https://docs.wizarr.dev/~gitbook/mcp).

# Reverse Proxy

## Trusted proxy headers

When Wizarr runs behind a reverse proxy such as Nginx, Traefik, Caddy, SWAG, or Nginx Proxy Manager, the browser may connect to the proxy over HTTPS while the proxy connects to Wizarr over plain HTTP.

Enable trusted proxy headers so Wizarr can use the original public request details when generating URLs and redirects.

Add the following environment variables to the Wizarr service:

```env
TRUST_PROXY_HEADERS=true
PROXY_FIX_X_FOR=1
PROXY_FIX_X_PROTO=1
PROXY_FIX_X_HOST=1
PROXY_FIX_X_PORT=1
PROXY_FIX_X_PREFIX=1
```

For a typical setup with one reverse proxy in front of Wizarr, use `1` for each `PROXY_FIX_*` value.

Only enable `TRUST_PROXY_HEADERS` when Wizarr is reachable only through your trusted reverse proxy. **Do not** enable it if clients can connect directly to the Wizarr container.

If Wizarr is behind multiple trusted proxy hops, increase the relevant `PROXY_FIX_*` value to match the number of trusted proxies.

## Passkeys

A passkey works at one address only. Passkeys need HTTPS and a domain name. Wizarr gets the passkey address (the WebAuthn RP ID and origin) as follows:

1. When you set both `WEBAUTHN_RP_ID` and `WEBAUTHN_ORIGIN`, Wizarr uses these values:

   ```env
   WEBAUTHN_RP_ID=wizarr.example.com
   WEBAUTHN_ORIGIN=https://wizarr.example.com
   ```
2. When you do not set them, Wizarr uses the address of the request. The first passkey registration keeps this address. On an instance that already has passkeys, the first passkey sign-in keeps it. While passkeys exist, Wizarr refuses passkey requests from a different address.

To move Wizarr to a new address, set the two environment variables. Or remove all passkeys (in the admin settings or with the recovery tool), then register the passkeys again at the new address.

We recommend that you set both variables when Wizarr is behind a reverse proxy.

## Rate limits

Wizarr limits the number of requests that one client IP can send to the sign-in, two-factor, password and invitation pages. A client that sends too many requests gets a "429 Too Many Requests" page with a `Retry-After` header.

| Route                                                        | Limit                                                                                                                    |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| Sign-in (`POST /login`, also LDAP)                           | Failed attempts only: 10 per minute and 50 per hour for each client IP and username, and 100 per hour for each client IP |
| `/complete-2fa`                                              | Failed attempts only: 10 per minute and 50 per hour for each pending sign-in, and 100 per hour for each client IP        |
| Passkey sign-in (complete), change password                  | 10 per minute and 50 per hour for each client IP                                                                         |
| Passkey sign-in (begin)                                      | 20 per minute and 100 per hour                                                                                           |
| Password reset link (`/reset/<code>`)                        | 10 per minute and 50 per hour                                                                                            |
| Invite page (`/j/<code>`), Plex sign-in return page          | 50 per minute                                                                                                            |
| Invite code page (`/join`), join forms, `/j/<code>/password` | 20 per minute                                                                                                            |
| First admin account (`POST /setup/`)                         | 10 per minute                                                                                                            |
| Create an invitation (admin)                                 | 30 per minute                                                                                                            |

The limits use the client IP that Wizarr sees. Behind a reverse proxy, set `TRUST_PROXY_HEADERS=true` (see above), so that the limits apply to each visitor. Without it, Wizarr sees the IP of the proxy for every visitor and counts all visitors together. Wizarr then logs a warning and shows a notice on the admin dashboard.

```env
RATELIMIT_ENABLED=true            # Set to false to turn off all rate limits
RATELIMIT_STORAGE_URI=memory://   # Where Wizarr keeps the counters
```

The default storage keeps the counters in memory, in each Wizarr process. The counters start again at zero when Wizarr restarts. If you set `GUNICORN_WORKERS` to more than 1, each worker has its own counters, so a client can send up to that number of times more requests. Other storages (`redis://`, `memcached://`, `mongodb://`) need a Python client library that the Wizarr image does not include. If the library is not installed, Wizarr does not start.

## Cookies and CSRF protection

Each form and each request that changes data must send a CSRF token. Wizarr adds the token to its pages, so you do not have to do anything. After an upgrade, reload the admin pages that were open before the upgrade.

For an uptime check, use `/health`. It does not make a session.

The session cookie and the "remember me" cookie have the `SameSite=Lax` and `HttpOnly` attributes. You can change these values:

| Variable                                              | Default             | Description                                                                                                                                                                                                                                                                                     |
| ----------------------------------------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SESSION_COOKIE_SAMESITE`, `REMEMBER_COOKIE_SAMESITE` | `Lax`               | `Lax`, `Strict` or `None`                                                                                                                                                                                                                                                                       |
| `SESSION_COOKIE_SECURE`, `REMEMBER_COOKIE_SECURE`     | `auto`              | Send the cookies only over HTTPS. `auto`: on each HTTPS request (behind a reverse proxy, this needs `TRUST_PROXY_HEADERS=true`). `true` or `false` sets the value for all requests                                                                                                              |
| `SESSION_COOKIE_HTTPONLY`, `REMEMBER_COOKIE_HTTPONLY` | `true`              | Do not let scripts read the cookies                                                                                                                                                                                                                                                             |
| `PERMANENT_SESSION_LIFETIME`                          | `604800` (7 days)   | Seconds without activity before the session ends                                                                                                                                                                                                                                                |
| `SESSION_FILE_THRESHOLD`                              | `10000`             | Number of session files before Wizarr removes some. It removes the expired sessions first, then the oldest sessions without a sign-in or a step in progress, then sessions with an invitation or sign-in step in progress, and signed-in sessions last. `0`: no limit. A value below 100 is 100 |
| `REMEMBER_COOKIE_DURATION`                            | `2592000` (30 days) | Seconds that "Remember me" keeps you signed in                                                                                                                                                                                                                                                  |
| `WTF_CSRF_TIME_LIMIT`                                 | `0`                 | Seconds that a CSRF token is valid. `0`: for the life of the session                                                                                                                                                                                                                            |
| `WTF_CSRF_SSL_STRICT`                                 | `false`             | On HTTPS, also require a `Referer` header from the same host                                                                                                                                                                                                                                    |

With `SameSite=Lax`, the browser does not send the Wizarr cookies when a page on a different site shows Wizarr in a frame (for example a dashboard on a different domain). Subdomains of one domain are the same site. To show the admin pages in a frame from a different site, use HTTPS and set `SESSION_COOKIE_SAMESITE=None`, `SESSION_COOKIE_SECURE=true`, `REMEMBER_COOKIE_SAMESITE=None` and `REMEMBER_COOKIE_SECURE=true`.

The REST API (`/api`) does not need a CSRF token when the request has an `X-API-Key` header.

## Nginx

{% tabs %}
{% tab title="SWAG" %}
Create a new file `wizarr.subdomain.conf` in `proxy-confs` with the following configuration:

```nginx
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name wizarr.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app wizarr;
        set $upstream_port 5690;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }

}
```

{% endtab %}

{% tab title="Nginx Proxy Manager" %}
Add a new proxy host with the following settings:

#### Details

* **Domain Names:** Your desired external wizarr hostname; e.g., `wizarr.example.com`
* **Scheme:** `http`
* **Forward Hostname / IP:** Internal wizarr hostname or IP
* **Forward Port:** `5690`
* **Cache Assets:** yes
* **Block Common Exploits:** no

#### SSL

* **SSL Certificate:** Select one of the options; if you are not sure, pick “Request a new SSL Certificate”
* **Force SSL:** yes
* **HTTP/2 Support:** yes
  {% endtab %}

{% tab title="Subdomain" %}
Add the following configuration to a new file `/etc/nginx/sites-available/wizarr.example.com.conf`:

```nginx
server {
    listen 80;
    server_name wizarr.example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name wizarr.example.com;

    ssl_certificate /etc/letsencrypt/live/wizarr.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/wizarr.example.com/privkey.pem;

    proxy_set_header Referer $http_referer;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Real-Port $remote_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on;

    location / {
        proxy_pass http://127.0.0.1:5690;
    }
}
```

Then, create a symlink to `/etc/nginx/sites-enabled`:

```bash
sudo ln -s /etc/nginx/sites-available/wizarr.example.com.conf /etc/nginx/sites-enabled/wizarr.example.com.conf
```

{% endtab %}
{% endtabs %}

## Traefik (v2)

Add the following labels to the wizarr service in your `docker-compose.yml` file:

```
labels:
  - "traefik.enable=true"
  ## HTTP Routers
  - "traefik.http.routers.wizarr-rtr.entrypoints=https"
  - "traefik.http.routers.wizarr-rtr.rule=Host(`wizarr.domain.com`)"
  - "traefik.http.routers.wizarr-rtr.tls=true"
  ## HTTP Services
  - "traefik.http.routers.wizarr-rtr.service=wizarr-svc"
  - "traefik.http.services.wizarr-svc.loadbalancer.server.port=5690"
```

For more information, please refer to the [Traefik documentation](https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/).

## Caddy

{% tabs %}
{% tab title="Subdomain" %}
Add the following site block to your Caddyfile:

```
wizarr.example.com {
    reverse_proxy http://127.0.0.1:5690
}
```

{% endtab %}

{% tab title="Path" %}
You need the [response replacement](https://github.com/caddyserver/replace-response) module to use this config.

Add the following site block to your Caddyfile:

```
plex.example.com {
    redir /wizarr /wizarr/admin

    handle_path /wizarr/* {
        replace {
            "href=\"/"      "href=\"/wizarr/"
            "action=\"/"    "action=\"/wizarr/"
            "\"/static"       "\"/wizarr/static"
            "hx-post=\"/"   "hx-post=\"/wizarr/"
            "hx-get=\"/"    "hx-get=\"/wizarr/"
            "scan=\"/"      "href=\"/wizarr/"
            "/scan"         "/wizarr/scan"
            # include in join code path copy
            "navigator.clipboard.writeText(url + \"/j/\" + invite_code);" "navigator.clipboard.writeText(url + \"/wizarr/j/\" + invite_code);"
        }

        # Your wizarr backend
        reverse_proxy http://127.0.0.1:5690
    }
    # Your main service that you want at /
    reverse_proxy http://127.0.0.1:5055
}
```

{% endtab %}
{% endtabs %}
