frp后台界面

Ubuntu ECS 和 局域网Mac做穿透

1. 背景

因为最近一直在研究AIGC,然后就心动的买了一台腾讯云服务器的体验版本,新用户60块钱,可以买15天GPU服务器,然后就一发不能收拾了。为什么不用阿里云?因为阿里云好像没有抓住这波AIGC的红利,也没有搞新用户拉新,所以就买了腾讯云。

为了不浪费这60大洋,我拼命的找业务场景,找应用,搭了stable diffusion的应用后,开启了API调用,然后就在公众号上 给大家提供了 文生图 和 图生图的功能,详见如下视频:

一顿操作猛如虎后,发现腾讯服务器再续费的时候 ,嘿嘿嘿了。

腾讯云GPU 服务器续费
腾讯云GPU 服务器续费

一年竟然要3W多,所以就考虑自己买个台式机,然后在家里跑图,然后就需要把局域网的机器,开放到公网来啦!然后就用到了 FRP。


## 通过下面命令查看架构
arch
或 
uname -a
然后再决定具体下载哪一个安装包。

## 下载安装包
wget https://github.com/fatedier/frp/releases/download/v0.49.0/frp_0.49.0_linux_386.tar.gz

## 然后解压
tar -zxvf frp_0.49.0_linux_386.tar.gz
## 文件改个名字
cp -r frp_0.49.0_linux_386 frp
# 把解压出来的文件夹复制到你想要的目录下,为了方便我直接放在用户目录下了,进入该目录
cd frp
# 查看一下文件
ls -a

root@ssevening:~/frp# ls
LICENSE  frpc  frpc.ini  frpc_full.ini  frps  frps.ini  frps_full.ini
  • frps.ini 文件配置如下:
bind_port = 7777
dashboard_port = 7788
token = pass
dashboard_user = admin
dashboard_pwd = pass
vhost_http_port = 7798
vhost_https_port = 7799
heartbeat configure, it's not recommended to modify the default value
the default value of heartbeat_timeout is 90
heartbeat_timeout = 90
#only allow frpc to bind ports you list, if you set nothing, there won't be any limit
privilege_allow_ports = 2000-3000,3001,3003,4000-50000

#pool_count in each proxy will change to max_pool_count if they exceed the maximum value
max_pool_count = 5

# max ports can be used for each client, default value is 0 means no limit
max_ports_per_client = 0

# authentication_timeout means the timeout interval (seconds) when the frpc connects frps
# if authentication_timeout is zero, the time is not verified, default is 900s
authentication_timeout = 900

# 支持外部访问的域名(需要将域名解析到IP)
subdomain_host = frp.xunl.net
  • 执行启动服务端。

    “`shell
    root@ssevening:~/frp# ./frps -c frps.ini
    2023/06/14 17:28:30 [I] [root.go:203] frps uses config file: frps.ini
    2023/06/14 17:28:31 [I] [service.go:208] frps tcp listen on 0.0.0.0:7777
    2023/06/14 17:28:31 [I] [service.go:269] http service listen on 0.0.0.0:7798
    2023/06/14 17:28:31 [I] [service.go:284] https service listen on 0.0.0.0:7799
    2023/06/14 17:28:31 [I] [service.go:320] Dashboard listen on 0.0.0.0:7788
    2023/06/14 17:28:31 [I] [root.go:212] frps started successfully
    “`

然后访问:http://xxx.xx.xx.xx:7788/ 进入后台。

frp后台界面
frp后台界面

这样服务端就算Ok了。

然后我们日后要后台运行。

nohup ./frps -c frps.ini &

下面我们搞MAC M1端

curl https://github.com/fatedier/frp/releases/download/v0.49.0/frp_0.49.0_darwin_arm64.tar.gz

或从这里下载:
https://xunlapk.oss-cn-hangzhou.aliyuncs.com/frp_0.49.0_linux_arm64.tar.gz

unzip frp_0.49.0_darwin_arm64.tar.gz

curl https://github.com/fatedier/frp/releases/download/v0.49.0/frp_0.49.0_darwin_arm64.tar.gz

或从这里下载:
https://xunlapk.oss-cn-hangzhou.aliyuncs.com/frp_0.49.0_linux_arm64.tar.gz

unzip frp_0.49.0_darwin_arm64.tar.gz

编辑 frpc.ini

内容如下

server_addr = 47.88.13.20
server_port = 7777
token = 你的密码

[rdp]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 7001

[smb]
type = tcp
local_ip = 127.0.0.1
local_port = 445
remote_port = 7002

[https-@.sample.cn]
type = https
# 填写实际域名
custom_domains = sample.cn
plugin = https2http
plugin_local_addr = 127.0.0.1:80

# HTTPS 证书相关的配置
plugin_crt_path = ./sample.cn.pem
plugin_key_path = ./sample.cn.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

./frpc -c frpc.ini

ssh -oPort=6000 pcx@47.88.13.20

然后开始搞活。

  • 备份和恢复数据库
  • “`bash
    echo "23. 连接远程mysql: mysql -h rm-rj9628l24688h63l8125010.mysql.rds.aliyuncs.com -u smartshop -p"
    echo "24. 导出mysql: mysqldump -h rm-rj9628l24688h63l8125010.mysql.rds.aliyuncs.com -u smartshop -p wordpress > /root/ssevening.sql —-HelloSmart"
    echo "25. 导入mysql: /usr/local/mysql/bin/mysql -h 127.0.0.1 -u root -p wordpress < ~/ssevening.sql"
    echo "26. 连接本地mysql /usr/local/mysql/bin/mysql -h localhost -u root -p"
    “`

1.报错ERROR 3546 (HY000) at line 24: @@GLOBAL.GTID_PURGED cannot be changed: the added gtid set must not overlap with @@GLOBAL.GTID_EXECUTED时,运行reset master;命令后重启mysql

  • docker 访问宿主机mysql
    用 host.docker.internal 这个 Hosts

类似文章

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注