# Configuration

## Introduction

VitoDeploy uses environment variables to configure the app.

If you've installed VitoDeploy on a VPS, You should see a `.env` file in the root of the project (
`/home/vito/vito/.env`). It is a normal Laravel env file which you can modify some of them.

If you are using the Docker version, you need to update the environment variables of your container.

## App URL

It is crucial to set the `APP_URL` environment variable to your Vito instance URL to ensure that features like Vito Logs
work properly.

## Email

To enable Vito to send you emails, You need to configure your mail server. Modify the following on the `.env` file

```dotenv
MAIL_HOST={YOUR-SMTP-HOST}
MAIL_PORT={YOUR-SMTP-PORT}
MAIL_USERNAME={YOUR-SMTP-USERNAME}
MAIL_PASSWORD={YOUR-SMTP-PASSWORD}
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS={YOUR-SMTP-MAIL-ADDRESS}
```

And then run the following commands inside the root directory of the project to apply the changes

```sh
php artisan optimize:clear
php artisan optimize
sudo supervisorctl restart worker:*
```

For docker version you will need to restart/re-create the container.

:::warning
Currently Vito supports only SMTP as the mail driver
:::

## Other Environment Variables

Beyond the basics, a few additional variables let you tune your instance. Most installs never need to
change these.

| Variable | Default | Description |
| --- | --- | --- |
| `SSH_USER` | `vito` | The Linux user Vito creates and uses to connect to managed servers. |
| `APP_PORT` | `8000` | The port the application listens on (Docker / local installs). |
| `APP_DEMO` | `false` | Enables demo mode, which disables destructive and instance-level actions (server creation, plugins, import/export). |
| `RESTRICTED_IP_ADDRESSES` | _(empty)_ | Comma-separated list of IP addresses that are not allowed as server IPs. |
| `KEY_PAIRS_DISK` | `key-pairs` | Filesystem disk used to store server SSH key pairs. |
| `SERVER_LOGS_DISK` | `server-logs` | Filesystem disk used to store server logs. |
| `SSH_PUBLIC_KEY_NAME` | `ssh-public.key` | Filename of the instance's SSH public key. |
| `SSH_PRIVATE_KEY_NAME` | `ssh-private.pem` | Filename of the instance's SSH private key. |

## Force HTTPS

To force HTTPS on your Vito instance, you need to set the `FORCE_HTTPS` environment variable to `true` in the `.env` file.

```dotenv
FORCE_HTTPS=true
```

This will activate the `URL::forceScheme('https')` or `URL::forceHttps()` in the Laravel application, ensuring that all URLs generated by the application use HTTPS.

## Realtime WebSocket

In v4.x Vito uses a built-in WebSocket server to push live updates to the UI. It works out of the
box, but the following environment variables let you configure and harden it.

### WS_BROADCAST_SECRET (recommended)

`WS_BROADCAST_SECRET` is the secret used to authenticate broadcasts to the WebSocket server. If it is
not set, Vito falls back to `APP_KEY` and logs a deprecation warning.

Setting a dedicated secret is recommended so your `APP_KEY` is not reused for broadcasting (which
reduces the risk of it leaking through logs or monitoring tools). Set it to a long random string:

```dotenv
WS_BROADCAST_SECRET={A-LONG-RANDOM-STRING}
```

You can generate one with:

```sh
openssl rand -base64 32
```

### WS_ALLOWED_ORIGINS

`WS_ALLOWED_ORIGINS` is a comma-separated list of origins allowed to connect to the WebSocket server,
used to prevent cross-site WebSocket hijacking. It defaults to your `APP_URL`.

```dotenv
WS_ALLOWED_ORIGINS="${APP_URL}"
```

### WS_URL

Set `WS_URL` if the WebSocket endpoint the browser connects to differs from your `APP_URL`, for
example during local development.

```dotenv
WS_URL=http://localhost
```

### WS_HOST and WS_PORT

These control the address the WebSocket server binds to on the host. They default to `127.0.0.1` and
`8085` respectively, and usually do not need changing.

:::info
After changing any of these values, apply the changes by running the following inside the project
root (or restart/re-create the container for the Docker version):

```sh
php artisan optimize:clear
php artisan optimize
sudo supervisorctl restart worker:*
```
:::