> For the complete documentation index, see [llms.txt](https://docs.spoof.dev/asteroid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spoof.dev/asteroid/configuration/proxy-and-multi-server.md).

# Proxy and Multi-Server

If you run several servers behind BungeeCord or Velocity, Asteroid can sync fake players across the whole network. They then appear in the proxy's global player list (`/glist`) and in network-wide placeholders like `%bungee_total%` and `%online_players%`.

```yaml
proxy:
  enabled: false
  resynchronization: true
  server_name: 'dev2'
  storage: "redis"
  redis:
    uri: "redis://:password@host:port/0"
```

## What you need

* Asteroid and AsteroidLibs installed on the proxy (BungeeCord or Velocity), not just the backend servers.
* A shared messaging backend every server can reach: Redis, Lettuce, or MySQL.

## Settings

| Setting             | What it does                                                                                                               |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `enabled`           | Turns multi-server sync on or off.                                                                                         |
| `resynchronization` | If a server or the proxy restarts, Asteroid re-syncs all fake players so the proxy and backend agree again. Leave this on. |
| `server_name`       | The name of this server exactly as your proxy config calls it.                                                             |
| `storage`           | The messaging backend. See below.                                                                                          |

`server_name` must match your proxy config exactly. If your Velocity or BungeeCord config lists this server as `survival`, then `server_name` must be `survival`, or the proxy will not track this server's fake players correctly.

## Choosing a backend

| Backend   | Notes                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------- |
| `redis`   | Recommended. Fast publish and subscribe messaging with low latency.                                     |
| `lettuce` | An async Redis client. Use it only if `redis` does not work for you.                                    |
| `mysql`   | Uses a MySQL table as a message queue. Works without Redis, but higher latency (polls every 2 seconds). |

## Setting up a free Redis database

If you do not already have Redis, you can get a free cloud database in a few minutes. Redis Cloud has a free tier that is more than enough for Asteroid's messaging.

Create a free account at [redis.io](https://redis.io/), then create a new database (the free plan is enough). Open it from the Databases list:

![Redis Cloud databases list](https://4195567042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpRR1OEuNyGq1PGnHucUc%2Fuploads%2FwSiSqNUbIJq0Brut7Z1s%2Fimage.png?alt=media\&token=db319de2-5316-42a5-8c64-30b3f4f5247c)

On the database page, use Connect to see the connection options:

![Connect to database](https://4195567042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpRR1OEuNyGq1PGnHucUc%2Fuploads%2F9n326JDGzT5vXvOISECP%2Fimage.png?alt=media\&token=cf66413f-685b-46e8-99a1-d6cb3c039abd)

Note the public endpoint (the host and port):

![Public endpoint](https://4195567042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpRR1OEuNyGq1PGnHucUc%2Fuploads%2FNbRozHaqihS3Dic5ZDI9%2Fimage.png?alt=media\&token=27b7d556-7110-40d0-93bb-635c051a280b)

The Redis CLI tab shows the full connection URI, including the password. Use these details to fill in the `uri` below:

![Redis CLI connection URI](https://4195567042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpRR1OEuNyGq1PGnHucUc%2Fuploads%2FXQ13yOQXH5JSLrhanFIV%2Fimage.png?alt=media\&token=8aba19e3-a1bc-4fa1-b49d-742f65e2d8f7)

## Redis connection URI

Used when `storage` is `redis` or `lettuce`. The format is `redis://[:password@]host[:port][/database]`.

| Situation                   | URI                                    |
| --------------------------- | -------------------------------------- |
| With a password             | `redis://:mypassword@localhost:6379/0` |
| No password                 | `redis://localhost:6379/0`             |
| Remote server with password | `redis://:test@192.168.1.50:6379/0`    |

### Passwords with special characters

The part between `redis://:` and the last `@` is your password. A password may contain almost anything, including an `@`, and Asteroid reads everything up to the final `@` as the password.

For example, if your real password is `gtd$9N13eMHMah!@8eCcGd`, this URI is correct:

```
redis://:gtd$9N13eMHMah!@8eCcGd@93.95.119.119:25578/3
```

Asteroid uses the last `@` as the separator, so the password keeps its own `@`, and the host is read as `93.95.119.119`. If a connection fails and the error shows a host that includes part of your password, check that the host and port after the final `@` are correct.

## MySQL as the backend

If you set `storage` to `mysql`, Asteroid uses the same MySQL connection from the Database section as the message queue. This avoids running Redis, at the cost of higher latency.
