前言
需要远程访问组里的服务器,就用frp来实现内网穿透,
另外还需要一台公网IP的服务器。
配置
服务端
wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_darwin_amd64.tar.gz
tar -xf frp_0.38.0_darwin_amd64.tar.gz
vim frp*amd64 /frps.ini
服务器端很简单
[common]
bind_port = 7000
vhost_http_port= 81
客户端
vim frp*aamd64/frpc.ini
假设公网服务器:
- IP是:1.2.3.4,
- 域名是domain.com,
- 解析的二级域名为 s i t e . d o m a i n . c o m site.domain.com site.domain.com(一级域名domain.com 也可以),但是也要解析到公网服务器的IP
[common]
tls_enable = true
server_addr = 1.2.3.4
server_port = 7000
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 607
[site]
type = http
local_ip = 127.0.0.1
local_port = 60700
custom_domains = site.domain.com
说明
- frps.ini中的bind_port和frpc.ini中的remote_port要一样
- 访问客户机上的网页要带上公网服务器的vhost_http_port(80可省略),这里是:http://site.domain.com:81
- ssh访问时要带上remote_port指定的端口,这里是:ssh -oPort=607 1.2.3.4或:ssh -oPort=607 user@domain.com
- 公网服务器要开启bind_port、vhost_http_port、remote_port对应的端口
- 客户机要开启local_port对应的端口
访问客户机时大致过程是这样的:
ssh:
ssh-oPort=607 user@1.2.3.4
时,会连接到公网服务器的607号端口,但是公网服务器的607号端口被客户机的remote_port指定了,所以公网服务器就把连接转发给客户机的对应的local_port端口(22)。
于是就连到客户机。
http:
http://site.domain.com:81
浏览器导航栏输入这个地址访问是,会把site.domain.com解析到公网服务器的81号端口,但是81号端口被客户机的remote_port指定了,所以公网服务器就把连接转发给客户机的对应的local_port端口(60700)。
于是就访问到客户机的网页了。
最后
以上就是追寻石头最近收集整理的关于ubuntu20.04 frp配置 内网穿透的全部内容,更多相关ubuntu20.04内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复