FRP实现内网穿透

一、准备

  • 公网服务器
  • 内网服务器(自己本地服务器)

二、安装frp服务端

2.1 公网服务器执行下面四条命令

# apt 更新
apt-get update

# 下载frps服务端脚本
wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh

# 修改脚本权限
chmod 700 ./install-frps.sh

# 执行脚本安装
./install-frps.sh install

2.2之后会让你输一些参数,直接一路回车默认值就可以了

==============================================
You Server IP      : 45.*******.194
Bind port          : 5443
KCP support        : true
vhost http port    : 80
vhost https port   : 443
Dashboard port     : 6443
token              : WK*******tDGI
tcp_mux            : true
Max Pool count     : 50
Log level          : info
Log max days       : 3
Log file           : enable
==============================================
frps Dashboard     : http://45.*******.194:6443/
Dashboard user     : ******
Dashboard password : ******
==============================================

2.3 浏览器访问控制面板、安装成功。

img

三、安装frp客户端

根据自己本地操作系统选择下载客户端 https://github.com/fatedier/frp/releases/

减压找到配置文件 frpc.ini

# 我的配置
# ./frpc -c ./frpc.ini
[common]
server_addr = 47.93.21.194
server_port = 5443
token = WKMRk7J3adu9tDGI

[web]
type = http
local_ip = 127.0.0.1
local_port = 80
# IP解析
custom_domains = 47.******.194
# 域名解析
# custom_domains = www.xxx.com

四、启动服务

4.1 首先启动本地服务器nginx、apache或者tomcat,确保 local_ip 127.0.0.1能够浏览器访问

img

127.0.0.1

4.2MAC(其他系统参考 frp github)下执行 ./frpc -c ./frpc.ini,验证外网ip访问本地服务器。

img

47.******.194

4.3 如果要实现域名访问内网,只需要域名解析服务端公网IP,服务端的服务器(nginx、apache或者tomcat)配置一下虚拟主机就可以了。

posted @ 2020-02-29 12:23  F兽  阅读(1071)  评论(0编辑  收藏  举报