惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

时间的朋友

Windows 命令行密码重置 Anaconda安装 typescript 注解解读1 Konvajs Shape加载自定义图片 sshpass 使用 why-is-node-running webgl笔记 SharedArrayBuffer is not defined blender 常用快捷键 | 时间的朋友 vue -- v3.4commit提交记录2 vue2 升级vue3报错问题整理 着色器 expressjs 源码 hyper-V arch linux 网络配置 element input数字格式化 three 拼接货架 WebAudio笔记 Windows nginx重启bat脚本 vue -- v3.4commit提交记录 URI malformed vue3 -- Class 对象在组件中使用范例 | 时间的朋友 ruby 安装和升级 element-plus 老版本cascader使用卡死问题 vue3 内置Transition组件 | 时间的朋友 前端memo的实现 | 时间的朋友 Vue -- vue-class-component源码 | 时间的朋友 linux 优化脚本 typescript 装饰器 | 时间的朋友 microbundle 源码 | 时间的朋友 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc
go Frp 工具使用 | 时间的朋友
2021-11-18 · via 时间的朋友

Published: · LastMod: November 23, 2021 · 521 words

frp使用 🔗

frp是golang开发的内网穿透工具,日常我们本地的服务由于公网ip不固定,外网无法访问,有了内网穿透工具,就可以很轻松的把我们的服务暴露给外网使用。

下载 🔗

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

这里我下载的是linux_amd64版本,根据自己需要下载

使用 🔗

frp分为服务端和客户端

Alt text

解压后 frp + sserver
解压后 frp + cclient

其中.ini为配置文件

frps.ini 🔗

1
2
3
[common]
bind_port = 7000 # frp 服务端暴露端口
vhost_http_port = 8099 # frp 客户端监听端口

frpc.ini 🔗

1
2
3
4
5
6
7
8
9
[common]
tls_enable = true # windows下客户端不能连接服务器问题
server_addr = your.remote.ip # 你的服务器ip
server_port = 7000 # 暴露端口

[web]
type = http # 类型
local_port = 8099 # 客户端端口
custom_domains = your.domain # 自定义域名

我们在 客户端上起一个服务

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
const http = require('http')

http.createServer(function(req, res){
   res.writeHead(200, { 'content-type': 'application/json' })
   res.end(JSON.stringify({
      data: 'success',
      code: 200
   }))
})
.listen(8099, function() {
    console.log(`listening at port 8099`)
})

在其他机器上访问 http://your.domain:8099 即可访问到原本本地的web服务

加入到系统命令中 🔗

systemd目录为自动脚本, 即linux中 service 命令对应的脚本

frps为例

  • 把可执行脚本frp 移动到 /usr/bin目录下

$ mv ./frps /usr/bin

  • 创建frp配置目录, 把 frps.ini 移动到该目录下

$ mkdir /etc/frp && mv frps.ini /etc/frp

  • 把相关自动执行脚本移动到systemd/system目录下

$ cd systemd && mv frps*service /etc/systemd/system

  • 启动

$ service frps start