1Panel通过Cloudflare反代哪吒gRPC
前置步骤:
登录Cloudflare,选择使用的域名。打开网络
选项将gRPC
开关打开。打开橙色云启用 CDN。
登录面板进入管理后台 打开设置页面,在未接入CDN的面板服务器域名/IP
中填入your_domain.com
,并保存
1.创建一个静态网站,启用HTTPS,配置文件全部替换(注意将 your_domain.com
替换为你的信息):
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name domain.com;
ssl_certificate /www/sites/your_domain.com/ssl/fullchain.pem;
ssl_certificate_key /www/sites/your_domain.com/ssl/privkey.pem;
ssl_stapling on;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
underscores_in_headers on;
keepalive_time 24h;
keepalive_requests 100000;
keepalive_timeout 120s;
location / {
proxy_pass http://127.0.0.1:8008;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
}
location ~ ^/(ws|terminal/.+)$ {
proxy_pass http://127.0.0.1:8008;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
}
location ^~ /proto.NezhaService/ {
grpc_read_timeout 300s;
grpc_send_timeout 300s;
grpc_socket_keepalive on;
grpc_pass grpc://grpcservers;
access_log off;
}
}
upstream grpcservers {
server 127.0.0.1:5555;
keepalive 512;
}
2.修改 /opt/nezha/dashboard/data/config.yaml
里的下面信息:
GRPCHost:domain.com
ProxyGRPCPort: 443
TLS: true
3.关闭通讯端口的外部访问,在 /opt/nezha/dashboard/docker-compose.yaml
中修改为:
ports:
- 127.0.0.1:8008:80
- 127.0.0.1:5555:5555
4.重启面板
评论