宝塔安装配置FRP+避坑指南

服务端配置文件

bindPort = 15443
kcpBindPort = 15443
webServer.port = 7001
webServer.user = "ZejtGELm"
webServer.password = "y48oNr9sQLWoypM4"
webServer.addr = "0.0.0.0"
dashboardPwd = "y48oNr9sQLWoypM4"
vhostHTTPPort = 18080
vhostHTTPSPort = 18443
log.file = "/var/log/frps.log"
log.level = "info"
log.maxDays = 30
auth.token = "1himX6uOstwBpEs3"
maxPoolCount = 50
tcpmuxHTTPConnectPort  = 16337
        

webServer.addr = “0.0.0.0” 重点-缺少这行导致无法访问网页版

客户端配置示例

serverAddr = "ip地址"
serverPort = 端口
#不能删除, 否则连接不上会闪退
loginFailExit=false
auth.token = "秘钥"
[[proxies]]
name = "test-tcp"
type = "tcp"
localIP = "192.168.1.0"
localPort = 566
remotePort = 566
[[proxies]]
name = "test-tcp-2"
type = "tcp"
localIP = "192.168.1.0"
localPort = 686
remotePort = 686
[[proxies]]
name = "biji"
type = "http"
localIP = "192.168.1.0"
localPort = 130
customDomains = ["bj.example.com"]
[[proxies]]
name = "yingshi"
type = "http"
localIP = "192.168.1.0"
localPort = 825
customDomains = ["ys.example.com"]    

frp 用 除去80 端口+ 宝塔做反代(如frp 用 18080 )

方法一(推荐):用宝塔面板操作

👉 步骤:

  1. 打开宝塔面板
  2. 进入 网站
  3. 添加站点:域名:example.com

(根目录随便填,比如 /www/wwwroot/example


  1. 进入该站点 → 点击反向代理:
  1. 添加代理:
项目填写
代理名称frp
目标URLhttp://127.0.0.1:18080
发送域名$host(很关键!)

👉 保存即可

方法二(直接写 Nginx 配置)

在宝塔网站配置里替换为:

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:18080;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
    }
}

四、最关键的一行(很多人会错)

👉 没有这行会发生:

👉 因为 frp 是靠 Host 判断转发的!


🌍 五、DNS 配置(必须正确)

example.com → 你的服务器公网IP


🚀 六、最终访问方式

http://example.com

👉 不需要端口 ✅
👉 自动走 frp ✅

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容