Almost working setup of Netbird behind Cloudlfare Proxy #1082

Open
opened 2025-11-20 05:23:43 -05:00 by saavagebueno · 7 comments
Owner

Originally created by @R-Nabil on GitHub (Jul 24, 2024).

Hi all,
Not sure if this is a bug, a setup issue (most likely) or a missing feature.
I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode).

My netbird is behind a traefik reverse proxy. If the CloudFlare proxy is deactivated, it works fine. If I activate it, it doesnt, and i believe the reason is because the IP of the devices are reported as the CloudFlare Proxy IP.

However, my traefik has been setup properly (to trust the headers), and the Traefik Logs are reporting the correct Client IP (device IP). SImilarly, im using a middleware that overrides the X-Real-IP by the correct IP.

However, Netbird still displays the proxy IP, and I guess because of that client can't P2P (as they are not reaching the appropriate IP).

I'm wondering if its :

  • My setup is partially correct and I've missed a step ?
  • There is something else that needs to be changed/configured on the Netbird side ?
  • Sthg else ?

Thank you in advnace

Originally created by @R-Nabil on GitHub (Jul 24, 2024). Hi all, Not sure if this is a bug, a setup issue (most likely) or a missing feature. I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode). My netbird is behind a traefik reverse proxy. If the CloudFlare proxy is deactivated, it works fine. If I activate it, it doesnt, and i believe the reason is because the IP of the devices are reported as the CloudFlare Proxy IP. However, my traefik has been setup properly (to trust the headers), and the Traefik Logs are reporting the correct Client IP (device IP). SImilarly, im using a middleware that overrides the X-Real-IP by the correct IP. However, Netbird still displays the proxy IP, and I guess because of that client can't P2P (as they are not reaching the appropriate IP). I'm wondering if its : - My setup is partially correct and I've missed a step ? - There is something else that needs to be changed/configured on the Netbird side ? - Sthg else ? Thank you in advnace
saavagebueno added the self-hosting label 2025-11-20 05:23:43 -05:00
Author
Owner

@lixmal commented on GitHub (Jul 24, 2024):

Hi @R-Nabil,

The management connection is not involved in the P2P process, that's why the displayed IP doesn't matter.

I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode).

Have you ditched the coturn server completely? You will still need the STUN functionality if your peers are behind NAT.
Can you provide a netbird status -dA from one of the clients?

(Please stick to the github template)

@lixmal commented on GitHub (Jul 24, 2024): Hi @R-Nabil, The management connection is not involved in the P2P process, that's why the displayed IP doesn't matter. > I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode). Have you ditched the coturn server completely? You will still need the STUN functionality if your peers are behind NAT. Can you provide a `netbird status -dA` from one of the clients? (Please stick to the github template)
Author
Owner

@R-Nabil commented on GitHub (Jul 24, 2024):

Hi @R-Nabil,

The management connection is not involved in the P2P process, that's why the displayed IP doesn't matter.

I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode).

Have you ditched the coturn server completely? You will still need the STUN functionality if your peers are behind NAT.

Can you provide a netbird status -dA from one of the clients?

(Please stick to the github template)

Realised I didn't answer to the message so I updated here:

First thanks for your answer.

  1. Noted regarding the management connection. I guess it would still be a nice to have to have correct IP but we can leave that one aside for now I agree.
  2. I haven't fully ditched them as they are still enabled in my docker-compose, but, they are not used (the VM hosting it hasn't opened the port for it). I want my "mobile" devices only to connect to home (where I have a static IP). My understanding is that it should not require TURN then ?
  3. Unfortunately I dont think I can ? As in, my first device is an iPhone, the device at home is a docker container (which doesn't seem to be able to call netbird status -dA ?).

DO let me know if i missed something.

@R-Nabil commented on GitHub (Jul 24, 2024): > Hi @R-Nabil, > > > > The management connection is not involved in the P2P process, that's why the displayed IP doesn't matter. > > > > > I'm trying to setup Netbird to be behind CloudFlare proxy (i do not plan on using Turn and have enabled the grpc mode). > > > > Have you ditched the coturn server completely? You will still need the STUN functionality if your peers are behind NAT. > > Can you provide a `netbird status -dA` from one of the clients? > > > > (Please stick to the github template) > > > > Realised I didn't answer to the message so I updated here: First thanks for your answer. 1. Noted regarding the management connection. I guess it would still be a nice to have to have correct IP but we can leave that one aside for now I agree. 2. I haven't fully ditched them as they are still enabled in my docker-compose, but, they are not used (the VM hosting it hasn't opened the port for it). I want my "mobile" devices only to connect to home (where I have a static IP). My understanding is that it should not require TURN then ? 3. Unfortunately I dont think I can ? As in, my first device is an iPhone, the device at home is a docker container (which doesn't seem to be able to call netbird status -dA ?). DO let me know if i missed something.
Author
Owner

@R-Nabil commented on GitHub (Jul 25, 2024):

As an update, I've done the below exercise :

I have one client at home (static IP, port forwarding setup correctly), and one mobile device. I aim at doing P2P direct connection only. The management is on a VPS with open ports for 443/3478 UDP

Current setup : No proxy, Netbird behind traefik -> Clients connect fine
Testing setup : Proxy enabled for all clients (so netbird.mydomain.com points to Cloudflare IP). Clients on the management interface show incorrect IP. P2P connection fails (it seems to try to connect to Cloudflare IP believing its the client IP). Traefik logs do show the correct IP (forwardedHeaders are trusted).
New Setup to confirm the suspicion : In my home DNS, i override the management interface to point to the VPS IP (bypassing locally the proxy). Now the home device shows correctly in the management interface, and P2P connection works.

So the issue definitely is linked to the devices not knowing each others IP when using Proxy.

I was pointed at the fact the CloudFlare proxy doesn't allow port 3478 through their proxy. Is this port really used when doing P2P connection ?

I've tried to use a supported port (I override turnserver.conf and management.json to use either 8443 UDP or 8443 TCP with no success).

Thanks

@R-Nabil commented on GitHub (Jul 25, 2024): As an update, I've done the below exercise : I have one client at home (static IP, port forwarding setup correctly), and one mobile device. I aim at doing P2P direct connection only. The management is on a VPS with open ports for 443/3478 UDP Current setup : No proxy, Netbird behind traefik -> Clients connect fine Testing setup : Proxy enabled for all clients (so netbird.mydomain.com points to Cloudflare IP). Clients on the management interface show incorrect IP. P2P connection fails (it seems to try to connect to Cloudflare IP believing its the client IP). Traefik logs do show the correct IP (forwardedHeaders are trusted). New Setup to confirm the suspicion : In my home DNS, i override the management interface to point to the VPS IP (bypassing locally the proxy). Now the home device shows correctly in the management interface, and P2P connection works. So the issue definitely is linked to the devices not knowing each others IP when using Proxy. I was pointed at the fact the CloudFlare proxy doesn't allow port 3478 through their proxy. Is this port really used when doing P2P connection ? I've tried to use a supported port (I override turnserver.conf and management.json to use either 8443 UDP or 8443 TCP with no success). Thanks
Author
Owner

@luckylinux commented on GitHub (Sep 15, 2024):

@R-Nabil: I cannot for the Life of me get Netbird to work with either Authentik nor Keycloak.

How did you setup Traefik exactly ? I'm having some Issues setting up the gRPC rules.

At the moment I only had the Dashboard reverse Proxy, but trying a Netbird Installation from Scratch using ./configure.sh I get these Warnings:

The following forwards have to be setup:
- https://netbird.MYDOMAIN.TLD:443 -http-> dashboard:80
- https://netbird.MYDOMAIN.TLD:443/api -http-> management:443
- https://netbird.MYDOMAIN.TLD:443/management.ManagementService/ -grpc-> management:443
- https://netbird.MYDOMAIN.TLD:443/signalexchange.SignalExchange/ -grpc-> signal:80
You most likely also have to change NETBIRD_MGMT_API_ENDPOINT in base.setup.env and port-mappings in docker-compose.yml.tmpl and rerun this script.
 The target of the forwards depends on your setup. Beware of the gRPC protocol instead of http for management and signal!
You are also free to remove any occurrences of the Letsencrypt-volume netbird-letsencrypt

@luckylinux commented on GitHub (Sep 15, 2024): @R-Nabil: I cannot for the Life of me get Netbird to work with either Authentik nor Keycloak. How did you setup Traefik exactly ? I'm having some Issues setting up the gRPC rules. At the moment I only had the Dashboard reverse Proxy, but trying a Netbird Installation from Scratch using `./configure.sh` I get these Warnings: ``` The following forwards have to be setup: - https://netbird.MYDOMAIN.TLD:443 -http-> dashboard:80 - https://netbird.MYDOMAIN.TLD:443/api -http-> management:443 - https://netbird.MYDOMAIN.TLD:443/management.ManagementService/ -grpc-> management:443 - https://netbird.MYDOMAIN.TLD:443/signalexchange.SignalExchange/ -grpc-> signal:80 You most likely also have to change NETBIRD_MGMT_API_ENDPOINT in base.setup.env and port-mappings in docker-compose.yml.tmpl and rerun this script. The target of the forwards depends on your setup. Beware of the gRPC protocol instead of http for management and signal! You are also free to remove any occurrences of the Letsencrypt-volume netbird-letsencrypt ```
Author
Owner

@CodeShellDev commented on GitHub (Feb 6, 2025):

Hi @luckylinux, have you found a solution to your problem?
I am also trying to setup NetBird behind Traefik and Cloudflare, but I can't get it to work,
the peer shows up in the dashboard but my client doesn't connect to my nebirdvpn

@CodeShellDev commented on GitHub (Feb 6, 2025): Hi @luckylinux, have you found a solution to your problem? I am also trying to setup NetBird behind Traefik and Cloudflare, but I can't get it to work, the peer shows up in the dashboard but my client doesn't connect to my nebirdvpn
Author
Owner

@luckylinux commented on GitHub (Feb 6, 2025):

Hi @CodeShellDev,

No unfortunately not 😞. I couldn't wait anymore so for some basic stuff I just setup a Wireguard Client/Server Point-to-Point Connection instead.

Nowadays I tend to prefer Caddy over Traefik, but I guess each has its own set of Advantages/Disadvantages. I might give it a try with Caddy at some Point.

However it doesn't look like I'll have some spare Time to do that anytime soon ...

@luckylinux commented on GitHub (Feb 6, 2025): Hi @CodeShellDev, No unfortunately not 😞. I couldn't wait anymore so for some basic stuff I just setup a Wireguard Client/Server Point-to-Point Connection instead. Nowadays I tend to prefer Caddy over Traefik, but I guess each has its own set of Advantages/Disadvantages. I might give it a try with Caddy at some Point. However it doesn't look like I'll have some spare Time to do that anytime soon ...
Author
Owner

@nazarewk commented on GitHub (May 15, 2025):

possibly related to Cloudflare settings discovered at https://github.com/netbirdio/netbird/issues/3716#issuecomment-2873282292 ?

@nazarewk commented on GitHub (May 15, 2025): possibly related to Cloudflare settings discovered at https://github.com/netbirdio/netbird/issues/3716#issuecomment-2873282292 ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1082