
使用场景: 生产环境下,有点比较严苛的场景,会禁止访问任何外网,但是有告警需要发出来,这种时候可以使用正向代理来解决。
项目地址 https://github.com/up-zero/my-proxy
生产环境使用的话,建议使用 supervisor或者systemd去控制。
帮助命令
> ./my-proxy
my-proxy CLI, support manage proxy, show proxy status etc.
Usage:
my-proxy [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
create create a new proxy service
delete delete the existing proxy service
edit edit a existing proxy service
help Help about any command
info get detailed information
restart restart proxy service
serve run daemon process for proxy service
start start proxy service
status get proxy service status, default get all service status
stop stop proxy service
version get my-proxy version
Flags:
-h, --help help for my-proxy
Use "my-proxy [command] --help" for more information about a command.
启动
> nohup ./my-proxy serve &
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
查看信息
> ./my-proxy info
my-proxy 1.0.0
+----------+-----------------------------+
| Address | http://192.168.31.181:12312 |
| Username | admin |
| Password | VIT9CJLj |
+----------+-----------------------------+
创建转发规则
根据提示输入相关的转发规则即可
> ./my-proxy create
Proxy Config
Type: [TCP] UDP HTTP
Name: proxy name
Listen Port: eg: 8080
Target Address: eg: 192.168.1.8
Target Port: eg: 8093
Use 'tab'/'shift+tab' or '↑'/'↓' to switch fields, '←'/'→' to select types, 'enter' to submit, 'q' or 'ctrl+c'
查看状态
下面是我配好的一个规则
> ./my-proxy status
+---+------+------+---------+-------------+----------------+-------------+
| # | NAME | TYPE | STATUS | LISTEN PORT | TARGET ADDRESS | TARGET PORT |
+---+------+------+---------+-------------+----------------+-------------+
| 1 | test | TCP | RUNNING | 8118 | 192.168.31.128 | 22 |
+---+------+------+---------+-------------+----------------+-------------+
(base) 编辑规则
> ./my-proxy edit test
Proxy Config
Type: [TCP] UDP HTTP
Name: test
Listen Port: 8118
Target Address: 192.168.31.128
Target Port: 22
Use 'tab'/'shift+tab' or '↑'/'↓' to switch fields, '←'/'→' to select types, 'enter' to submit, 'q' or 'ctrl+c'
连接测试
> ssh -p 8118 root@192.168.31.181
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。