frp 是一個可用於內網穿透的高性能的反向代理應用
支持 tcp, udp, http, https 協議。
下載frp檔

wget https://github.com/fatedier/frp/releases/download/v0.16.0/frp_0.16.0_linux_amd64.tar.gz

解壓縮

tar -zxvf  frp_0.16.0_linux_amd64.tar.gz

客戶端:啟動frpc指令
windows

frpc.exe -c frpc.ini

Linux

./frpc -c ./frpc.ini

伺服器端:啟動frps指令
windows

./frps.exe -c ./frps.ini

Linux

./frps -c ./frps.ini

伺服器端相關配置:

[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
bind_addr = 0.0.0.0
bind_port = 7000
# udp port used for kcp protocol, it can be same with 'bind_port'
# if not set, kcp is disabled in frps
kcp_bind_port = 7000
# if you want to configure or reload frps by dashboard, dashboard_port must be set
dashboard_port = 7500
# dashboard assets directory(only for debug mode)
dashboard_user = king
dashboard_pwd = Happydaygo4
# assets_dir = ./static

vhost_http_port = 8080
vhost_https_port = 443
# console or real logFile path like ./frps.log
log_file = ./frps.log
# debug, info, warn, error
log_level = info
log_max_days = 3
# privilege mode is the only supported mode since v0.10.0
privilege_token = rpLjPOgPWDiaZKDe
# only allow frpc to bind ports you list, if you set nothing, there won't be any limit
#privilege_allow_ports = 1-65535
# pool_count in each proxy will change to max_pool_count if they exceed the maximum value
max_pool_count = 50
# if tcp stream multiplexing is used, default is true
tcp_mux = true

客戶端相關配置:

# [common] is integral section
[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
server_addr = 46.101.193.84
server_port = 7000

# if you want to connect frps by http proxy, you can set http_proxy here or in global environment variables
# it only works when protocol is tcp
# http_proxy = http://user:pwd@192.168.1.128:8080

# console or real logFile path like ./frpc.log
log_file = ./frpc.log

# trace, debug, info, warn, error
log_level = info

log_max_days = 3

# for authentication
privilege_token = rpLjPOgPWDiaZKDe

# set admin address for control frpc's action by http api such as reload
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = king
admin_pwd = Happydaygo4

# connections will be established in advance, default value is zero
pool_count = 5

# if tcp stream multiplexing is used, default is true, it must be same with frps
tcp_mux = true

# decide if exit program when first login failed, otherwise continuous relogin to frps
# default is true
login_fail_exit = true

# communication protocol used to connect to server
# now it supports tcp and kcp, default is tcp
protocol = tcp
[web]
type = http
local_port = 80
custom_domains = digital.kingcloud.tk

用nohup讓frp在後台運行

nohup ./frps -c ./frps.ini &

查看及終止 nohup

jobs -l 
kill -9 1040 這個1040是PID碼 找到nohup ./frps -c ./frps.ini &

開機啟動腳本

  1. 在/etc/systemd/system底下建立frp.service
  2. chmod 754 frp.service
  3. vim frp.service #添加以下腳本
[Unit]
Description=FRP Service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
ExecStart=/root/frp/frps -c /root/frp/frps.ini
Restart=always
RestartSec=1min
ExecStop=/usr/bin/killall frps

[Install]
WantedBy=multi-user.target
  1. 相關啟動方式
systemctl start frp.service #啟動frp
systemctl stop frp.service  #停止frp
systemctl enable frp.service #新增開機自啟

來源位置:
https://github.com/fatedier/frp

Last modification:November 30, 2018
If you think my article is useful to you, please feel free to appreciate