# Agent
A sample [Relay Mail](https://gitlab.com/relay-mail/docs/-/wikis/home) Agent.
## Install
Write a Docker Compose file which pulls `registry.gitlab.com/relay-mail/rust/agent/relay-agent:latest` and run it.
Forward all traffic to `localhost:2526` with a reverse proxy like [NGINX](https://nginx.org/).
Make sure to use HTTPS, all connections require it.
### Example `compose.yml`
```yml
services:
db:
image: postgres:16
container_name: relay-postgres
restart: unless-stopped
environment:
POSTGRES_USER: relay
POSTGRES_PASSWORD: relay
POSTGRES_DB: relay
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U relay -d relay"]
interval: 5s
timeout: 5s
retries: 5
agent:
image: registry.gitlab.com/relay-mail/rust/agent/relay-agent:latest
container_name: relay-agent
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
AGENT_DOMAIN: example.org
DATABASE_URL: postgres://relay:relay@db/relay
AGENT_ADDRESS: 0.0.0.0
AGENT_PORT: 2525
RUST_LOG: info
ports:
- "2525:2525"
volumes:
pgdata:
```
### Example NGINX server
```text
server {
listen 2525 ssl;
listen [::]:2525 ssl;
server_name _;
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
location / {
proxy_pass http://127.0.0.1:2526;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
```