frp反向代理web应用

frp 是什么

frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, http, https 协议。

github: https://github.com/fatedier/frp

类似的

  1. localtunnel https://github.com/localtunnel/localtunnel
  2. ngrok https://ngrok.com/

frp 能干什么

将处于内网的服务通过外网机器映射出去,公司内网有些服务需要能够在外网访问,这个应该是成本最低的解决方法,比如nas,内网路由器管理映射等等。

frp 的文档已经很详细了。由于是使用go开发的,所以,整个安装只有四个文件

  • frps 服务端
  • frs.ini 服务端配置
  • frpc 客户端
  • frpc.ini 客户端配置

相比其他的程序来说,frp 使用起来简单方便。

1
2
3
4
5
6
7
8
9
10
#服务端启动
./frps -c frps.ini
#服务端启动 后台执行
# nohup ./frps -c frps.ini &  

# 客户端启动
./frpc -c frpc.ini
#客户端端启动 后台执行
# nohup ./frps -c frps.ini &

frps.ini 配置

1
2
3
4
5
[common]
bind_port = 7000           # 监听端口
vhost_http_port = 6001     # http 端口, client 端的http会被转到这个端口
subdomain_host = xxxx.com # 绑定的主域名 ,在dns里面设置好绑定,与 frpc.ini 中的 subdomain 一起使用

frpc.ini 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
[common]
server_addr = 192.168.1.110 # server 端域名
server_port = 7000   # server 端监听端口


[web01]           # http 服务穿透 必须以 web 开头
type = http         # 服务类型 http or https
local_port = 8080   # web服务本机端口
subdomain = web # 服务的域名,与server端的subdomain_host配和使用,访问域名为 www.xxxx.com

#http_user =admin   # 访问需要登录,测试发现认证失败,问题原因不详。
#http_pwd =admin

作为反向代理来说,最常用的就是代理 web 服务或者是 ssh。frp 配置起来非常简单。 作者在发布的 build 的 zip 文件中提供了全量配置选项。

作者

张巍

发布于

2018-11-29

更新于

2018-11-29

许可协议

评论