-
Notifications
You must be signed in to change notification settings - Fork 125
More complete documentation for setting up Crowdsec and the proxy manually. #784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,15 +72,18 @@ The proxy authenticates with the management server using an access token. Genera | |
| ```bash | ||
| docker exec -it netbird-server /go/bin/netbird-server token create \ | ||
| --name "my-proxy" --config <netbird-data-dir>/config.yaml | ||
|
|
||
| # NOTE: <netbird-data-dir> is usually located at `/etc/netbird`. | ||
| ``` | ||
|
|
||
|
|
||
| **Multi-container** (separate `netbirdio/management` image): | ||
|
|
||
| ```bash | ||
| docker exec -it netbird-management /go/bin/netbird-mgmt token create --name "my-proxy" | ||
| ``` | ||
|
|
||
| This outputs a token in the format `nbx_...` (40 characters). **Save the token immediately** - it is only displayed once. The management server stores only a SHA-256 hash. | ||
| This outputs a token in the format `nbx_...` (40 characters). **Save the token immediately** - it is only displayed once. The management server stores only a SHA-256 hash. Make sure not to accidentally copy the 20 character Token ID instead. | ||
|
|
||
| You can manage tokens later with: | ||
|
|
||
|
|
@@ -263,7 +266,7 @@ A CrowdSec LAPI (Local API) container runs alongside your deployment, syncs deci | |
| | **enforce** | Blocked IPs are denied immediately. If the bouncer is not yet synced, connections are denied (fail-closed). | | ||
| | **observe** | Blocked IPs are logged but not denied. Use this to evaluate CrowdSec before enforcing. | | ||
|
|
||
| #### 7a. Add the CrowdSec container | ||
| #### 7a. Add the CrowdSec container and configure Traefik/proxy. | ||
|
|
||
| Add the following service to your `docker-compose.yml`: | ||
|
|
||
|
|
@@ -303,6 +306,35 @@ Add `crowdsec_db:` to the `volumes:` section, and update the proxy's `depends_on | |
| condition: service_healthy | ||
| ``` | ||
|
|
||
| Inside the configuration for the `traefik` service, inside the `command:` section, add: | ||
| ```yaml | ||
| - "--providers.file.filename=/etc/traefik/dynamic.yaml" | ||
| ``` | ||
|
|
||
| Inside the `traefik` service `volumes:` section, add: | ||
| ```yaml | ||
| - ./traefik-dynamic.yaml:/etc/traefik/dynamic.yaml:ro | ||
| ``` | ||
|
|
||
| Inside the `proxy` service `labels:` section, add: | ||
| - traefik.tcp.services.proxy-tls.loadbalancer.serverstransport=pp-v2@file~ | ||
|
|
||
| Finally, create a new file called `traefik-dynamic.yaml` containing the following: | ||
| ```yaml | ||
| tcp: | ||
| serversTransports: | ||
| pp-v2: | ||
| proxyProtocol: | ||
| version: 2 | ||
| ``` | ||
|
|
||
|
|
||
| Then restart Traefik, we will restart the proxy later. | ||
|
|
||
| ```bash | ||
| docker compose up -d traefik | ||
| ``` | ||
|
|
||
| #### 7b. Start CrowdSec and register a bouncer | ||
|
|
||
| ```bash | ||
|
|
@@ -331,6 +363,9 @@ Add these lines to `proxy.env`: | |
| ```bash | ||
| NB_PROXY_CROWDSEC_API_URL=http://crowdsec:8080 | ||
| NB_PROXY_CROWDSEC_API_KEY=<bouncer-key-from-above> | ||
| NB_PROXY_FORWARDED_PROTO=https | ||
| NB_PROXY_PROXY_PROTOCOL=true | ||
| NB_PROXY_TRUSTED_PROXIES=172.30.0.10 | ||
|
Comment on lines
+366
to
+368
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded Traefik IP doesn't match the main migration flow. Line 368 sets Without a matching static IP, the proxy won't trust Traefik's actual Docker IP when parsing client addresses from the proxy protocol headers, which will break CrowdSec's IP reputation enforcement. Impact: CrowdSec will either fail to identify client IPs correctly or block legitimate traffic. Consider one of these solutions: Option 1 (recommended): Use subnet notation instead of a single IP to trust the entire Docker network: -NB_PROXY_TRUSTED_PROXIES=172.30.0.10
+NB_PROXY_TRUSTED_PROXIES=172.30.0.0/24Option 2: Add static IP configuration to Step 7a before the CrowdSec container instructions: Expand to see proposed addition to Step 7aAdd this subsection before "Add the following service to your First, assign a static IP to Traefik so the proxy can trust it:
```yaml
networks:
netbird:
driver: bridge
ipam:
config:
- subnet: 172.30.0.0/24
gateway: 172.30.0.1
services:
traefik:
# ...existing traefik config...
networks:
netbird:
ipv4_address: 172.30.0.10This ensures <Note>
Replace `<traefik-container-ip>` with your Traefik container's IP address on the Docker network. Find it by running:
```bash
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <traefik-container-name>🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| Then restart the proxy: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyphenate the compound adjective.
"20 character" should be hyphenated when used as a compound adjective before a noun.
📝 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~86-~86: Use a hyphen to join words.
Context: ...ake sure not to accidentally copy the 20 character Token ID instead. You can man...
(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents