wget https://github.com/fatedier/frp/releases/download/v0.20.0/frp_0.20.0_linux_amd64.tar.gz
frps.ini 服务端 有外网IP服务器
frpc.ini 客户端 局域网服务器
服务端:
vi frps.ini
[common]
bind_port = 8700
token = asdasdasdasdasdasdasd
vi start_frp_server.sh
nohup ./frps -c frps.ini > frps.log 2>&1 &
vi stop_frp_server.sh
kill -9 $(ps -aux |grep frps |grep -v grep |awk '{print $2}')
修改权限
chmod 777 start_frp_server.sh
chmod 777 stop_frp_server.sh
启动frp
./start_frp_server.sh
关闭frp
./stop_frp_server.sh
客户端:
vi frpc.ini
[common]
server_addr = #服务端IP
server_port = 8700
token = asdasdasdasdasdasdasd[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 8702[web]
type = tcp
local_ip = 127.0.0.1
local_port = 80
remote_port = 8701
vi start_frp_server.sh
nohup ./frpc -c frpc.ini > frpc.log 2>&1 &
vi stop_frp_server.sh
kill -9 $(ps -aux |grep frps |grep -v grep |awk '{print $2}')
类似客户端步骤操作然后启动。
http://服务端ip:8701 通过外网IP访问局域网
通过域名访问:
反向代理配置nginx
location / {proxy_pass http://服务端IP:8701/;proxy_redirect http:// https://; client_max_body_size 100M;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $host;}