部署Frps实现内网穿透

准备

安装gcc

yum -y update

yum install -y autoconf automake bzr gcc libtool make mercurial subversion

安装go

yum install -y epel-release

yum install golang

go version #查看go版本

下载Frps

wget https://github.com/fatedier/frp/releases/download/v0.48.0/frp_0.48.0_linux_amd64.tar.gz
tar -zxvf frp_0.48.0_linux_amd64.tar.gz
mv frp_0.48.0_linux_amd64 frp
cd frp
rm -f frpc frpc_full.ini frpc.ini
ls

配置Frps

配置文件示例:frps_full.ini

# [common] 是一个重要的配置段
[common]

# 绑定地址,0.0.0.0 表示所有网络接口
bind_addr = 0.0.0.0

# 绑定端口号
bind_port = 7000

# kcp 协议的 UDP 端口,可以和 bind_port 相同
kcp_bind_port = 7000

# quic 协议的 UDP 端口
# 如果不设置,则表示禁用 quic
# quic_bind_port = 7002

# quic 协议选项
# quic_keepalive_period = 10
# quic_max_idle_timeout = 30
# quic_max_incoming_streams = 100000

# 指定代理监听的地址,默认与 bind_addr 相同
# proxy_bind_addr = 127.0.0.1

# 如果您想支持虚拟主机,必须设置 HTTP 的监听端口(可选)
# 注意:HTTP 端口和 HTTPS 端口可以与 bind_port 相同
vhost_http_port = 80
vhost_https_port = 443

# 虚拟主机 HTTP 服务器的响应超时时间(秒),默认为 60 秒
# vhost_http_timeout = 60

# tcpmux_httpconnect_port 指定服务器侦听 TCP 的 HTTP CONNECT 请求的端口。
# 如果值为 0,则服务器不会在一个单一端口上多路复用 TCP 请求。
# 默认情况下,该值为 0。
# tcpmux_httpconnect_port = 1337

# 如果 tcpmux_passthrough 为 true,则 frps 不会对流量进行任何更改。
# tcpmux_passthrough = false

# 设置 dashboard_addr 和 dashboard_port 来查看 frps 的仪表板
# dashboard_addr 的默认值与 bind_addr 相同
# 仅当设置了 dashboard_port 时,仪表板才可用
dashboard_addr = 0.0.0.0
dashboard_port = 7500

# 仪表板的用户名和密码,用于基本认证保护
dashboard_user = admin
dashboard_pwd = admin

# 仪表板的 TLS 模式
dashboard_tls_mode = false
# dashboard_tls_cert_file = server.crt
# dashboard_tls_key_file = server.key

# enable_prometheus 将在 {dashboard_addr}:{dashboard_port} 上的 /metrics API 导出 Prometheus 指标。
enable_prometheus = true

# 仪表板资源目录(仅用于调试模式)
# assets_dir = ./static

# 控制台或实际日志文件路径,比如 ./frps.log
log_file = ./frps.log

# 日志级别:trace, debug, info, warn, error
log_level = info

# 日志最大保存天数
log_max_days = 3

# 当 log_file 是控制台时,禁用日志颜色,默认为 false
disable_log_color = false

# 是否向 frpc 发送详细错误(带有调试信息)。默认为 true。
detailed_errors_to_client = true

# 认证方法,指定如何使用认证 frpc 与 frps
# 如果指定为 "token",将在登录消息中使用 token
# 如果指定为 "oidc",将使用 OIDC(Open ID Connect)设置发布 OIDC 令牌
# 默认情况下,该值为 "token"
authentication_method = token

# 在心跳消息中是否包含身份验证令牌。默认为 false。
authenticate_heartbeats = false

# 是否在新建立的工作连接中包含身份验证令牌。默认为 false。
authenticate_new_work_conns = false

# 认证令牌
token = 12345678

# oidc_issuer 指定用于验证 OIDC 令牌的发布者。
# 默认情况下,该值为空字符串。
oidc_issuer =

# oidc_audience 指定在验证时 OIDC 令牌应包含的受众。
# 默认情况下,该值为空字符串。
oidc_audience =

# oidc_skip_expiry_check 指定是否跳过检查 OIDC 令牌是否过期。
# 默认情况下,该值为 false。
oidc_skip_expiry_check = false

# oidc_skip_issuer_check 指定是否跳过检查 OIDC 令牌的发布者声明是否与 OidcIssuer 中指定的发布者匹配。
# 默认情况下,该值为 false。
oidc_skip_issuer_check = false

# 心跳配置,不建议修改默认值
# heartbeat_timeout 默认为 90。将其设置为负值可禁用心跳。
# heartbeat_timeout = 90

# 用户连接超时时间,默认为 10 秒
# user_conn_timeout = 10

# 只允许 frpc 绑定您列出的端口,如果什么都不设置,则没有任何限制
allow_ports = 2000-3000,3001,3003,4000-50000

# 每个代理中的 pool_count 如果超过了最大值,将变更为 max_pool_count
max_pool_count = 5

# 每个客户端可以使用的最大端口数,默认值为 0 表示无限制
max_ports_per_client = 0

# 是否只接受 TLS 加密的连接。默认为 false。
tls_only = false

# tls_cert_file = server.crt
# tls_key_file = server.key
# tls_trusted_ca_file = ca.crt

# 如果 subdomain_host 不为空,则可以在 frpc 的配置文件中为类型为 http 或 https 的服务设置子域名
# 当 subdomain 为 test 时,路由所使用的主机是 test.frps.com
subdomain_host = frps.com

# 如果使用了 tcp 流多路复用,默认为 true
# tcp_mux = true

# 指定 TCP 多路复用的保活间隔。
# 仅当 tcp_mux 为 true 时有效。
# tcp_mux_keepalive_interval = 60

# tcp_keepalive 指定 frpc 与 frps 之间活动网络连接上保持活动探测之间的间隔。
# 如果值为负数,则禁用保活探测。
# tcp_keepalive = 7200

# HTTP 请求自定义 404 页面
# custom_404_page = /path/to/404.html

# 指定 UDP 数据包大小,单位为字节。如果不设置,默认值为 1500。
# 此参数应该在客户端和服务器之间相同。
# 它影响 UDP 和 SUDP 代理。
udp_packet_size = 1500

# 在仪表板监听器中启用 golang pprof handlers。
# 必须首先设置仪表板端口
pprof_enable = false

# NAT 打洞策略数据的保留时间。
nat_hole_analysis_data_reserve_hours = 168

[plugin.user-manager]
addr = 127.0.0.1:9000
path = /handler
ops = Login

[plugin.port-manager]
addr = 127.0.0.1:9001
path = /handler
ops = NewProxy

其中有用的如下

# [common] is integral section
[common]                    # common部分是整体配置

bind_addr = 0.0.0.0          # 绑定地址为0.0.0.0,即监听所有网络接口
bind_port = 7000             # 绑定端口为7000

kcp_bind_port = 7000         # KCP协议使用的UDP端口,可以与bind_port相同
# quic_bind_port = 7002      # QUIC协议使用的UDP端口

vhost_http_port = 80         # 支持虚拟主机的HTTP监听端口
vhost_https_port = 443       # 支持虚拟主机的HTTPS监听端口

dashboard_addr = 0.0.0.0     # Dashboard绑定的IP地址
dashboard_port = 7500        # Dashboard监听的端口

dashboard_user = admin       # Dashboard登录用户名
dashboard_pwd = admin        # Dashboard登录密码

enable_prometheus = true     # 启用Prometheus指标数据的导出

log_file = ./frps.log        # 日志文件路径
log_level = info             # 日志级别

disable_log_color = false    # 禁用日志颜色

detailed_errors_to_client = true   # 向frpc发送详细的错误信息

authentication_method = token      # 鉴权方式为token
authenticate_heartbeats = false    # 在心跳中不包含鉴权令牌
authenticate_new_work_conns = false    # 在新的工作连接中不包含鉴权令牌

token = 12345678             # 鉴权令牌

oidc_skip_expiry_check = false     # 不跳过OIDC令牌过期检查
oidc_skip_issuer_check = false     # 不跳过OIDC令牌的Issuer匹配检查

allow_ports = 2000-3000,3001,3003,4000-50000    # 允许frpc绑定的端口范围

max_pool_count = 5          # 每个代理的最大连接池数
max_ports_per_client = 0    # 每个客户端可以使用的最大端口数,0表示无限制

tls_only = false            # 是否只接受TLS加密连接

subdomain_host = frps.com   # 子域名的主机名后缀

tcp_mux = true              # 是否启用TCP流复用

udp_packet_size = 1500      # UDP数据包大小

pprof_enable = false        # 是否启用Dashboard监听器的golang pprof处理程序

nat_hole_analysis_data_reserve_hours = 168   # NAT穿透策略数据保留时间

此外,还有两个插件配置部分:

[plugin.user-manager]
addr = 127.0.0.1:9000
path = /handler
ops = Login

[plugin.port-manager]
addr = 127.0.0.1:9001
path = /handler
ops = NewProxy

修改配置文件 frps.ini

[common]

# frp 绑定端口
bind_addr = 0.0.0.0
bind_port = 7000	

# http端口监听
vhost_http_port = 800
# https端口监听
vhost_https_port = 4430

dashboard_addr = 0.0.0.0
# Dashboard监听的端口
dashboard_port = 7500

dashboard_user = 用户名
dashboard_pwd = 密码

log_file = /root/frp/frps.log

# 域名
subdomain_host=

# token
token = 12345678

启动Frps

cd /root/frp
./frps -c frps.ini

查看日志

cat /root/frp/frps.log

配置自启动

cd /lib/systemd/system
vim frps.service

frps.service配置

[Unit]
Description=frps
[Service]
Type=simple
ExecStart=/root/frp/frps -c /root/frp/frps.ini
[Install]
WantedBy=multi-user.target
systemctl enable frps # 开机自启
systemctl disable frps # 关闭开机自启
systemctl start frps
systemctl stop frps
systemctl restart frps
systemctl status frps

Frpc配置

部署Frps实现内网穿透插图
感谢观看部署Frps实现内网穿透,欢迎分享https://cn-lcx.cn/2023/08/07/1112/
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇