Skip to content
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

How can I set up a self-hosted service on ports other than 80 and 443? #1420

Open
CafeBabe202 opened this issue Dec 30, 2023 · 7 comments
Open

Comments

@CafeBabe202
Copy link

I am using the method in the documentation to build a self-hosted service, but there are other websites on my server that need to use ports 443 and 80. How can I create my netbird service on other ports?

@mlsmaycon
Copy link
Collaborator

Hello @CafeBabe202, it depends on your webserver, the doc https://docs.netbird.io/selfhosted/selfhosted-guide#configuration-for-your-reverse-proxy list the path that you need to rewrite, the important piece is that you need to enable HTTP2, forward to grpc upstreams according to the path.

Here you find an example for nginx and traefik:

The only service that can't be behind the webserver is the relay, for that you need to open the UDP ports listed in the requirements.

@jiangslee
Copy link

jiangslee commented Jan 6, 2024

@CafeBabe202 老哥,你试一下这个修改端口号的快速脚本。 #1410

https://raw.githubusercontent.com/jiangslee/netbird/main-custom-ports-ssl-certs/infrastructure_files/getting-started-with-zitadel.sh

操作步骤:

  1. mkdir certs
  2. 在certs目录放好与域名一致的证书文件,如netbird.my-domain.com.pemnetbird.my-domain.com.key
~/docker-netbird# tree certs
certs
├── netbird.my-domain.com.key
└── netbird.my-domain.com.pem
  1. export NETBIRD_DOMAIN=netbird.my-domain.com
  2. bash getting-started-with-zitadel.sh
  3. 按提示输入好端口号(请提前进行域名解释和及安全组端口放行:你自定义的端口号,比如我上图的TCP:8088,8443; UDP ports: 3478, 49152-65535)

大概这样
image

@Ten-Night
Copy link

老哥,你试一下这个修改端口号的快速脚本。#1410

https://raw.githubusercontent.com/jiangslee/netbird/main-custom-ports-ssl-certs/infrastructure_files/getting-started-with-zitadel.sh

操作步骤:

  1. mkdir certs
  2. 在certs目录放好与域名一致的证书文件,如,netbird.my-domain.com.pem``netbird.my-domain.com.key
~/docker-netbird# tree certs
certs
├── netbird.my-domain.com.key
└── netbird.my-domain.com.pem
  1. export NETBIRD_DOMAIN=netbird.my-domain.com
  2. bash getting-started-with-zitadel.sh
  3. 按提示输入好端口号(请提前进行域名解释和及安全组端口放行:你自定义的端口号,比如我上图的TCP:8088,8443;UDP 端口:3478、49152-65535)

大概这样 图像

已经正常运行,但是一登录后跳转到/peers 开始了无限期的等待

/nb-auth?code=pUDIIH_9DCbTNKE0ahEeKXhfPsr5jwEOthYeeOo8LS1GA&state=1mEhRw9kph
404 Not Found

最后一直在请求
/api/users
502 Bad Gateway

可以帮助我解决这个问题吗

@Ten-Night
Copy link

@CafeBabe202 老哥,你试一下这个修改端口号的快速脚本。 #1410

https://raw.githubusercontent.com/jiangslee/netbird/main-custom-ports-ssl-certs/infrastructure_files/getting-started-with-zitadel.sh

操作步骤:

  1. mkdir certs
  2. 在certs目录放好与域名一致的证书文件,如netbird.my-domain.com.pemnetbird.my-domain.com.key
~/docker-netbird# tree certs
certs
├── netbird.my-domain.com.key
└── netbird.my-domain.com.pem
  1. export NETBIRD_DOMAIN=netbird.my-domain.com
  2. bash getting-started-with-zitadel.sh
  3. 按提示输入好端口号(请提前进行域名解释和及安全组端口放行:你自定义的端口号,比如我上图的TCP:8088,8443; UDP ports: 3478, 49152-65535)

大概这样 image

2024-04-26T17:19:25Z INFO management/cmd/management.go:455: loading OIDC configuration from the provided IDP configuration endpoint https://n1.net:7443/.well-known/openid-configuration
Error: failed reading provided config file: /etc/netbird/management.json: failed fetching OIDC configuration from endpoint https://n1.net:7443/.well-known/openid-configuration Get "https://n1.net:7443/.well-known/openid-configuration": dial tcp 222.187.22.13:7443: i/o timeout

@jiangslee
Copy link

@Ten-Night 大概率是你的端口不可访问导致的问题,建议你排查一下域名解释及端口放行。

1、检查安全组端口放行

我这里是用8088替代80端口、8443替代443端口,UDP与原文档一致3478, 49152-65535
image

如果你服务器装了宝塔,可能还要在宝塔-安全页面开放上述端口(主要是开启了Linux防火墙)

2、一键quickstart脚本跑起来,按提示填写自定义端口安装netbird

以下是改端口部署的最新脚本,建议使用。

~# cd /root/docker-netbird/
~/docker-netbird# tree ./certs
certs
├── netbird.my-domain.com.key
└── netbird.my-domain.com.pem
~/docker-netbird# export NETBIRD_DOMAIN=netbird.yourdomain.com && bash <(curl -sSL https://raw.githubusercontent.com/jiangslee/netbird/main-jsl/infrastructure_files/getting-started-with-zitadel.sh)
The NETBIRD_HTTP_PORT variable cannot be empty.
Enter the http port you want to use for NetBird (e.g. 80): 8088
The NETBIRD_3478_PORT variable cannot be empty.
Enter the TURN_LISTENING_PORT you want to use for NetBird (e.g. 3478): 3478
The NETBIRD_PORT variable cannot be empty.
Enter the https port you want to use for NetBird (e.g. 443): 8443
Rendering initial files...

Initializing Zitadel's CockroachDB


[+] Running 7/7
 ✔ crdb Pulled                                                                                                                                                                                      19.4s 
   ✔ 868d60b3f5d4 Pull complete                                                                                                                                                                      4.3s 
   ✔ d680d21f63a9 Pull complete                                                                                                                                                                      0.8s 
   ✔ e6325911d345 Pull complete                                                                                                                                                                      0.9s 
   ✔ ac854e9a30bb Pull complete                                                                                                                                                                     11.0s 
   ✔ a269fdca3aeb Pull complete                                                                                                                                                                      2.0s 
   ✔ f18f484123b4 Pull complete                                                                                                                                                                      3.5s 
[+] Running 7/7
 ✔ Network docker-netbird_netbird                 Created                                                                                                                                            0.1s 
 ✔ Volume "docker-netbird_netbird_caddy_data"     Created                                                                                                                                            0.0s 
 ✔ Volume "docker-netbird_netbird_management"     Created                                                                                                                                            0.0s 
 ✔ Volume "docker-netbird_netbird_zitadel_certs"  Created                                                                                                                                            0.0s 
 ✔ Volume "docker-netbird_netbird_crdb_data"      Created                                                                                                                                            0.0s 
 ✔ Volume "docker-netbird_netbird_crdb_certs"     Created                                                                                                                                            0.0s 
 ✔ Container docker-netbird-crdb-1                Started 
# 省略很多行...
 ✔ management Pulled                                                                                                                                                                                16.2s 
   ✔ bccd10f490ab Pull complete                                                                                                                                                                      4.9s 
   ✔ 69282076af0b Pull complete                                                                                                                                                                      6.0s 
   ✔ e58f9567d72f Pull complete                                                                                                                                                                      0.9s 
[+] Running 7/7
 ✔ Container docker-netbird-management-1  Started                                                                                                                                                    0.5s 
 ✔ Container docker-netbird-coturn-1      Started                                                                                                                                                    0.5s 
 ✔ Container docker-netbird-signal-1      Started                                                                                                                                                    0.5s 
 ✔ Container docker-netbird-crdb-1        Healthy                                                                                                                                                    0.0s 
 ✔ Container docker-netbird-caddy-1       Running                                                                                                                                                    0.0s 
 ✔ Container docker-netbird-dashboard-1   Started                                                                                                                                                    0.5s 
 ✔ Container docker-netbird-zitadel-1     Running                                                                                                                                                    0.0s 

Done!

You can access the NetBird dashboard at https://netbird.yourdomain.com:8443
Login with the following credentials:
Username: [email protected]
Password: 8bxpzu/++6aL*********NYR9L6aL4DI@

@jiangslee
Copy link

@CafeBabe202 老哥,你试一下这个修改端口号的快速脚本。 #1410
https://raw.githubusercontent.com/jiangslee/netbird/main-custom-ports-ssl-certs/infrastructure_files/getting-started-with-zitadel.sh
操作步骤:

  1. mkdir certs
  2. 在certs目录放好与域名一致的证书文件,如netbird.my-domain.com.pemnetbird.my-domain.com.key
~/docker-netbird# tree certs
certs
├── netbird.my-domain.com.key
└── netbird.my-domain.com.pem
  1. export NETBIRD_DOMAIN=netbird.my-domain.com
  2. bash getting-started-with-zitadel.sh
  3. 按提示输入好端口号(请提前进行域名解释和及安全组端口放行:你自定义的端口号,比如我上图的TCP:8088,8443; UDP ports: 3478, 49152-65535)

大概这样 image

2024-04-26T17:19:25Z INFO management/cmd/management.go:455: loading OIDC configuration from the provided IDP configuration endpoint https://n1.net:7443/.well-known/openid-configuration Error: failed reading provided config file: /etc/netbird/management.json: failed fetching OIDC configuration from endpoint https://n1.net:7443/.well-known/openid-configuration Get "https://n1.net:7443/.well-known/openid-configuration": dial tcp 222.*..13:7443: i/o timeout

你这个是家宽的IP?然后你的域名指向了这个家宽IP?这个IP:222.***.**.13确定是你的公网IP??

@jiangslee
Copy link

有个Q群可以交流一下,群号:677407258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants