要是公司电脑配置够,我何至于此

流程

  之前配置过我的世界服务器,这次步骤差不多。服务端配置如下

[common]
bind_port = 和内网机通信端口

# 面板端口
dashboart_port = 查看 frp 信息的端口
# 登录面板账号设置
dashboard_user = 账号
dashboard_pwd = 密码

# 身份验证
token = 自己设定
vhost_http_port = 服务端对外 web 服务的端口

[http]
# 设置 http 协议下的代理端口
type = http
vhost_http_port = 服务端对外 web 服务的端口

[desktop]
type = tcp
local_port = 服务端对外远程桌面的端口
listen_port = 服务端对外远程桌面的端口

  客户端配置如下

[common]
server_addr = 服务端 ip
server_port = 服务端和内网通信端口

[web]
type = http
local_port = 80 # 本地开启 web 服务的端口
custom_domains = feifeitan.cn # 这个是服务端的域名,切记不能不配置,不配置会报错,配置错了也会无法访问。
vhost_http_port =  服务端对外 web 服务的端口 # 好吧,我不知道有啥用,可能是冗余的,但我跑起来就懒得管了

[desktop]
type = tcp
local_port = 3389 # 远程桌面服务端口
remote_port = 服务端对外远程桌面的端口

使用 ./frps -c frps.ini 来启动 frps 服务端。如果需要后台执行,则使用 nohup ./frps -c frps.ini >/dev/null 2>&1 &

  启动 frp 客户端:frpc.exe -c frpc.ini

常见问题及解决方案

配置frp报错start error: type [http] not support when vhost_http_port is not set
   网上的解决办法纯属扯淡,解决办法是将 vhost_http_port 在服务端的common 中也添加一个。

do http proxy request [host:www.xxx.xxx] error: no root found: www.xxx.xxx
   出现原因是客户端配置域名访问和访问的域名不匹配
  解决办法是将客户端的custom_domains 配置的域名必须和浏览器访问的域名一致。比如我这里就是feifeitan

访问的时候各种 404,403之类的
   出现原因是,网站本体我配置了 TLS ,但是搭建的远程靶场环境没有 tls,浏览器输入访问的时候默认加上了,还有就是输入url时候忘记添加端口。

网页的html加载出来了,但是css和图片都没有加载出来
   原因是前面配置的时候,输入的是局域网的IP,局域网请求资源也是通过公网请求这个 IP,导致请求失败。解决方案是进入网站后台,将对外 ip 设置成 服务端 ip:服务端对外端口。

  frp报错 while decoding JSON: json: cannot unmarshal string into Go value of type
bind_addr这种ip地址就是字符串,是必须加双引号的,如果不加,在启动frps时就会报错误