# Server Settings (/configuration/server)



The `[server]` section controls how Rustinx listens for connections and manages resources.

## Full Reference [#full-reference]

```toml title="rustinx.toml"
[server]
listen = "0.0.0.0:9090"       # Address and port to bind
behind_proxy = false           # Trust X-Forwarded-For headers
trusted_proxy_depth = 1        # Number of proxy hops to trust
max_connections = 1024         # Max concurrent connections
connection_timeout = 30        # Seconds before killing idle connections
max_file_size = 52428800       # Max file size in bytes (50MB)
```

## listen [#listen]

The address and port Rustinx binds to.

| Value              | Meaning                             |
| ------------------ | ----------------------------------- |
| `"0.0.0.0:9090"`   | All interfaces, port 9090 (default) |
| `"127.0.0.1:9090"` | Localhost only                      |
| `"0.0.0.0:8080"`   | All interfaces, port 8080           |

## behind\_proxy [#behind_proxy]

When `true`, Rustinx reads the client IP from `X-Forwarded-For` or `X-Real-IP` headers instead of the TCP connection. Only enable this when Rustinx is behind a trusted reverse proxy.

**Default**: `false`

```toml
[server]
behind_proxy = true
trusted_proxy_depth = 1  # Traefik = 1 hop
```

The `trusted_proxy_depth` controls which IP to extract from the `X-Forwarded-For` chain. It counts from the right:

```text
X-Forwarded-For: client, traefik
                   ^--- depth=1 picks this one
```

If the chain is shorter than the configured depth, Rustinx falls back to the direct connection IP. This prevents spoofing.

**Range**: `trusted_proxy_depth` must be 1-16.

## Resource Limits [#resource-limits]

These limits protect the server from resource exhaustion:

| Setting              | Default         | Range              | Purpose                             |
| -------------------- | --------------- | ------------------ | ----------------------------------- |
| `max_connections`    | 1024            | 1-4096             | Max concurrent TCP connections      |
| `connection_timeout` | 30              | 1-3600             | Seconds before killing a connection |
| `max_file_size`      | 52428800 (50MB) | 1-1073741824 (1GB) | Largest file that will be served    |

Files larger than `max_file_size` return `413 File Too Large`.

### Example: Low-resource container [#example-low-resource-container]

```toml
[server]
max_connections = 64
connection_timeout = 10
max_file_size = 10485760  # 10MB
```
