# HTTPS and reverse proxies

Access keys travel in every request, so serve FuzzyShare over HTTPS. FuzzyShare itself speaks plain HTTP: put a reverse proxy in front.

> [!WARNING]
> Over plain HTTP, keys and files are exposed on the network. The CLI warns when it would send a key over `http` to anything but localhost.

## Caddy

Caddy gets and renews certificates for you.

```
fuzzyshare.example.com {
    reverse_proxy 127.0.0.1:8080
}
```

## nginx

Uploads are streamed to disk, so turn request buffering off and allow your largest file:

```
server {
    server_name fuzzyshare.example.com;
    client_max_body_size 50m;
    proxy_request_buffering off;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
```

Add your TLS certificate directives (for example with certbot).

## Tell FuzzyShare about the proxy

```sh
FUZZY_TRUST_PROXY=true
FUZZY_PUBLIC_URL=https://fuzzyshare.example.com
```

- `FUZZY_TRUST_PROXY=true` reads the client address from `X-Forwarded-For`. Without it every visitor looks like the proxy, which breaks the signup rate limit, the passphrase limit and the link activity log.
- `FUZZY_PUBLIC_URL` is the address used in links, install snippets, `robots.txt`, the sitemap and these docs.

Only enable `FUZZY_TRUST_PROXY` when a proxy you control is the sole way to reach FuzzyShare, otherwise a client can forge its address.

## Request timeouts

Request bodies have no read timeout, so large uploads can be slow. For hostile networks, give the proxy its own timeouts.

## Check it

```sh
curl -sS https://fuzzyshare.example.com/health
```

It returns `{"status":"ok"}`.

## A separate app hostname

By default the web app lives at `/dashboard` on your main address. Set `FUZZY_APP_HOST=app.example.com` to serve it on its own hostname instead, at the root: `app.example.com/files`, `app.example.com/keys`, and no `/dashboard` anywhere. The main host keeps the site, docs and share links, and sends `/dashboard`, `/access` and `/signup` to the app host.

It is the same server, so the proxy sends both hostnames to it and must keep the `Host` header (Caddy and nginx's `proxy_set_header Host $host` do):

```text
example.com, www.example.com, app.example.com {
    reverse_proxy 127.0.0.1:8080
}
```

The API answers on both hosts. A saved access key belongs to the address it was saved on, so people sign in again on the app host once.
