多域名转发

参考教程:[frp + Nginx实现内网穿透 配置多个子域名访问内部服务](https://blog.csdn.net/codeblf2/article/details/103752247) # 服务器端 修改“/root/frp/frp_0.34.3_linux_amd64”目录下的“frps.ini”配置文件 ```js [common] #服务端监听的端口,默认是7000,可自定义 bind_port = 7000 #为HTTP类型代理监听的端口 vhost_http_port = 7600 #鉴权使用的 token 值 token = password2020 #启用 Dashboard 监听的本地端口 dashboard_port = 7500 dashboard_user = admin dashboard_pwd = zhaoxuan ``` 在nigix中添加如下配置: ```js ##通过Nginx反向代理进行端口转发 #树莓派负载均衡池 upstream frp_http_raspberry{ server 127.0.0.1:7600; } #树莓派端口转发 server { listen 80; #需转发的域名。多个域名用空格隔开。二级域名可用*表示。 server_name *.jidongyun.cn *.goldarts.cn; access_log /www/wwwlogs/access.log; #将所有请求转发给frp_http池的应用处理 location / { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://frp_http_raspberry; } } ``` 保存后,重载Nginx配置即可。 # 树莓派端 修改"/home/pi/frp/frp_0.34.3_linux_arm64"目录下的“frpc.ini”配置文件 其中server_addr 是服务器IP地址 ```js [common] server_addr = 120.76.103.117 server_port = 7000 token = password2020 http_proxy = [web01] type = http local_ip = 127.0.0.1 local_port = 7601 custom_domains = pi.jidongyun.cn [web02] type = http local_ip = 127.0.0.1 local_port = 7602 custom_domains = api.goldarts.cn ``` 转发更多域名的例子: ``` [common] server_addr = 120.76.103.117 server_port = 7000 token = password2020 http_proxy = [web02] type = http local_ip = 127.0.0.1 local_port = 7602 custom_domains = api.goldarts.cn [web03] type = http local_ip = 127.0.0.1 local_port = 7603 custom_domains = cloud.goldarts.cn [web04] type = http local_ip = 127.0.0.1 local_port = 7612 custom_domains = bpi.feiyunjs.com [web05] type = http local_ip = 127.0.0.1 local_port = 7613 custom_domains = cloud.feiyunjs.com [web06] type = http local_ip = 127.0.0.1 local_port = 7614 custom_domains = cpi.feiyunjs.com [web07] type = http local_ip = 127.0.0.1 local_port = 7615 custom_domains = bpi.jidongyun.cn [web08] type = http local_ip = 127.0.0.1 local_port = 7616 custom_domains = document.feiyunjs.com ``` ### 重启应用 sudo systemctl restart frpc