|
1 | 1 | --- |
2 | 2 | title: Environment Variables |
3 | | -description: Comprehensive guide to environment configuration |
| 3 | +description: Core runtime configuration for CrowdSec Manager |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Environment Variables |
7 | 7 |
|
8 | | -CrowdSec Manager is configured primarily through environment variables passed to the Docker container. |
| 8 | +The minimum deployment needs only a small environment set. Add more variables only when your paths or container names differ. |
9 | 9 |
|
10 | | -## Summary |
| 10 | +## Minimum variables (recommended) |
11 | 11 |
|
12 | | -**Are any variables absolutely necessary?** |
13 | | -Technically, **no**. The application is designed with sensible defaults for all configuration options. You can run the application without setting any environment variables, provided the default paths (like `./data` and `./logs`) are writable and Docker is available locally. |
14 | | - |
15 | | -## Detailed Variable Breakdown |
16 | | - |
17 | | -### Core Application Configuration |
18 | | - |
19 | | -| Variable | Default | Impact / Description | |
20 | | -| :--- | :--- | :--- | |
21 | | -| `PORT` | `8080` | The HTTP port the manager listens on. Change this if port 8080 is already in use. | |
22 | | -| `ENVIRONMENT` | `production` | Sets the application mode. Use `development` for verbose logging and dev features. | |
23 | | -| `LOG_LEVEL` | `info` | Controls logging verbosity. Options: `debug`, `info`, `warn`, `error`. | |
24 | | -| `LOG_FILE` | `/app/logs/crowdsec-manager.log` | Path where the application log file is written. | |
25 | | - |
26 | | -### Docker & Service Discovery |
27 | | - |
28 | | -| Variable | Default | Impact / Description | |
| 12 | +| Variable | Example | Purpose | |
29 | 13 | | :--- | :--- | :--- | |
30 | | -| `DOCKER_HOST` | `unix:///var/run/docker.sock` | Address of the Docker daemon. If empty, it uses the default local socket. Set this if connecting to a remote Docker instance. | |
31 | | -| `COMPOSE_FILE` | `/app/docker-compose.yml` | Path to the Docker Compose file. The manager reads this to discover services and manage updates. | |
32 | | -| `*_CONTAINER_NAME` | `crowdsec`, `traefik`, etc. | Overrides for container names if your stack uses different names (e.g., `CROWDSEC_CONTAINER_NAME`, `TRAEFIK_CONTAINER_NAME`). | |
33 | | -| `PANGOLIN_DIR` | `/app` | Base working directory for the application. | |
34 | | -| `CONFIG_DIR` | `/app/config` | Directory where configuration files are stored. | |
| 14 | +| `PORT` | `8080` | HTTP port inside the container. | |
| 15 | +| `ENVIRONMENT` | `production` | Runtime mode. | |
| 16 | +| `TRAEFIK_DYNAMIC_CONFIG` | `/etc/traefik/dynamic_config.yml` | Traefik dynamic config path used by manager actions. | |
| 17 | +| `TRAEFIK_CONTAINER_NAME` | `traefik` | Traefik container name in your stack. | |
| 18 | +| `TRAEFIK_STATIC_CONFIG` | `/etc/traefik/traefik_config.yml` | Traefik static config path. | |
35 | 19 |
|
36 | | -### File Paths & Persistence |
| 20 | +## Common optional variables |
37 | 21 |
|
38 | | -| Variable | Default | Impact / Description | |
| 22 | +| Variable | Default | When to change | |
39 | 23 | | :--- | :--- | :--- | |
40 | | -| `DATABASE_PATH` | `/app/data/settings.db` | Location of the SQLite database storing app settings. Ensure this path is persistent. | |
41 | | -| `BACKUP_DIR` | `/app/backups` | Directory where backups are stored. | |
42 | | -| `RETENTION_DAYS` | `60` | Number of days to keep backups before auto-deletion. | |
43 | | - |
44 | | -### Integrations (Traefik & CrowdSec) |
45 | | - |
46 | | -| Variable | Default | Impact / Description | |
47 | | -| :--- | :--- | :--- | |
48 | | -| `TRAEFIK_DYNAMIC_CONFIG` | `/etc/traefik/dynamic_config.yml` | Path to Traefik's dynamic config file. Used to manage middlewares/routers. | |
49 | | -| `TRAEFIK_STATIC_CONFIG` | `/etc/traefik/traefik_config.yml` | Path to Traefik's static config file. | |
50 | | -| `TRAEFIK_ACCESS_LOG` | `/var/log/traefik/access.log` | Path to read Traefik access logs from. | |
51 | | -| `TRAEFIK_ERROR_LOG` | `/var/log/traefik/traefik.log` | Path to read Traefik error logs from. | |
52 | | -| `CROWDSEC_ACQUIS_FILE` | `/etc/crowdsec/acquis.yaml` | Path to CrowdSec's acquisition configuration. | |
53 | | -| `INCLUDE_CROWDSEC` | `true` | Whether to manage CrowdSec container updates/restarts. | |
54 | | - |
55 | | -## Recommendation |
56 | | - |
57 | | -For a standard deployment, you likely only need to configure: |
58 | | -1. **`PORT`**: If you have a port conflict. |
59 | | -2. **`COMPOSE_FILE`**: If your compose file is not in the default location. |
60 | | -3. **`DOCKER_HOST`**: If running in a complex Docker environment. |
61 | | - |
62 | | -Everything else can safely be left to defaults unless you have specific customization needs (like changing log locations or backup retention). |
63 | | - |
64 | | -## Handling Custom Paths |
65 | | - |
66 | | -A common source of confusion is the difference between **internal container paths** (where the app looks for files) and **external host paths** (where files actually exist on your server). |
67 | | - |
68 | | -### The Golden Rule |
69 | | - |
70 | | -- **Environment Variables** tell the application **where to look inside the container**. |
71 | | -- **Docker Volumes** map your **real host files** to those **internal container locations**. |
72 | | - |
73 | | -### Example: Custom CrowdSec Installation |
74 | | - |
75 | | -Suppose your CrowdSec installation is at `/opt/my-custom-crowdsec` instead of the standard `/etc/crowdsec`. |
76 | | - |
77 | | -**DO NOT** change the environment variable `CROWDSEC_ACQUIS_FILE` to `/opt/my-custom-crowdsec/acquis.yaml`. The container cannot see your `/opt` directory directly! |
78 | | - |
79 | | -**Instead, update your `docker-compose.yml` volumes:** |
80 | | - |
81 | | -```yaml |
82 | | -services: |
83 | | - crowdsec-manager: |
84 | | - environment: |
85 | | - # LEAVE THIS AS DEFAULT |
86 | | - - CROWDSEC_ACQUIS_FILE=/etc/crowdsec/acquis.yaml |
87 | | - volumes: |
88 | | - # Map YOUR custom path (left) to the CONTAINER'S expected path (right) |
89 | | - - /opt/my-custom-crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml:ro |
90 | | -``` |
91 | | -
|
92 | | -By changing the volume mapping, you "trick" the container into seeing your custom file at the standard location it expects. This is almost always the correct way to handle custom paths. |
93 | | -
|
94 | | -### Common Customization Examples |
95 | | -
|
96 | | -Here are examples for the most common customization requests. In all cases, **keep the environment variable at its default value** and change the volume mapping in `docker-compose.yml`. |
97 | | - |
98 | | -#### 1. Custom CrowdSec Configuration Folder |
99 | | - |
100 | | -If your CrowdSec configuration is stored in `/mnt/security/crowdsec`: |
101 | | - |
102 | | -```yaml |
103 | | -services: |
104 | | - crowdsec-manager: |
105 | | - environment: |
106 | | - - CROWDSEC_ACQUIS_FILE=/etc/crowdsec/acquis.yaml # Default |
107 | | - volumes: |
108 | | - # Map your custom folder to the standard location |
109 | | - - /mnt/security/crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml:ro |
110 | | -``` |
111 | | - |
112 | | -#### 2. Custom Traefik Logs Location |
113 | | - |
114 | | -If your Traefik logs are stored in `/var/log/custom-traefik`: |
115 | | - |
116 | | -```yaml |
117 | | -services: |
118 | | - crowdsec-manager: |
119 | | - environment: |
120 | | - - TRAEFIK_ACCESS_LOG=/var/log/traefik/access.log # Default |
121 | | - - TRAEFIK_ERROR_LOG=/var/log/traefik/traefik.log # Default |
122 | | - volumes: |
123 | | - # Map your custom log directory to the standard location |
124 | | - - /var/log/custom-traefik:/var/log/traefik:ro |
125 | | -``` |
126 | | - |
127 | | -#### 3. Custom Traefik Configuration File |
128 | | - |
129 | | -If your Traefik static configuration is at `/opt/traefik/traefik.toml`: |
130 | | - |
131 | | -```yaml |
132 | | -services: |
133 | | - crowdsec-manager: |
134 | | - environment: |
135 | | - - TRAEFIK_STATIC_CONFIG=/etc/traefik/traefik_config.yml # Default |
136 | | - volumes: |
137 | | - # Map your custom config file to the standard location |
138 | | - - /opt/traefik/traefik.toml:/etc/traefik/traefik_config.yml:ro |
139 | | -``` |
140 | | - |
141 | | -#### 4. Custom Traefik Dynamic Configuration |
142 | | - |
143 | | -If your dynamic configuration is at `/opt/traefik/dynamic/rules.yml`: |
144 | | - |
145 | | -```yaml |
146 | | -services: |
147 | | - crowdsec-manager: |
148 | | - environment: |
149 | | - - TRAEFIK_DYNAMIC_CONFIG=/etc/traefik/dynamic_config.yml # Default |
150 | | - volumes: |
151 | | - # Map your custom dynamic config to the standard location |
152 | | - - /opt/traefik/dynamic/rules.yml:/etc/traefik/dynamic_config.yml:ro |
153 | | -``` |
154 | | - |
155 | | -#### 5. Custom CrowdSec Manager Logs |
| 24 | +| `DATABASE_PATH` | `/app/data/settings.db` | If you store app data elsewhere in container. | |
| 25 | +| `BACKUP_DIR` | `/app/backups` | If backup path is customized in container. | |
| 26 | +| `LOG_LEVEL` | `info` | For troubleshooting (`debug`) or quieter logs. | |
| 27 | +| `RETENTION_DAYS` | `60` | To change backup retention policy. | |
156 | 28 |
|
157 | | -If you want the manager's own logs to be stored in `/var/log/crowdsec-manager`: |
| 29 | +## Notes |
158 | 30 |
|
159 | | -```yaml |
160 | | -services: |
161 | | - crowdsec-manager: |
162 | | - environment: |
163 | | - - LOG_FILE=/app/logs/crowdsec-manager.log # Default |
164 | | - volumes: |
165 | | - # Map your custom log directory to the standard location |
166 | | - - /var/log/crowdsec-manager:/app/logs |
167 | | -``` |
| 31 | +- Keep environment values as in-container paths. |
| 32 | +- Use Docker volume mappings to map host paths to those container paths. |
| 33 | +- Multi-proxy support is not available in this release. |
0 commit comments