frp内网穿透配置
准备工作
- 申请一台有公网ip的服务器,腾讯云、阿里云等等。
- 一个域名,并将域名解析到所申请服务器上。
frp服务端配置
- 下载frp
wget https://github.com/fatedier/frp/releases/download/v0.13.0/frp_0.13.0_linux_amd64.tar.gz
- 解压
tar -zxvf frp_0.13.0_linux_amd64.tar.gz
- 修改frps.ini配置文件,
bind_port
为frp服务器运行的端口号,vhost_http_port
为http访问的端口号[common] bind_port = 7000 vhost_http_port = 8080
- 启动
./frps -c ./frps.ini
- 后台运行frps
nohup ./frps -c ./frps.ini &
- 要停止通过nohup启动的程序,我们需要先找到程序的进程id,然后kill掉
查找进程id:
ps -ef|grep frps
或者
lsof -i:7000
结束进程:
kill -9 3769
frp客户端配置
- 根据系统下载对应的frp包:https://github.com/fatedier/frp/releases
- 解压
- 修改frpc.ini
[common]
server_addr = 139.199.227.223
server_port = 7000
[web]
type = http
local_port = 5000
custom_domains = www.findsunshine.site
说明:
server_addr
为服务器ip
server_port
为frp服务器运行的端口
local_port
为本地web服务运行的端口
custom_domains
为解析到服务器上的域名
- 启动
frpc.exe -c frpc.ini
- 测试
配置好后,我们通过
http://www.findsunshine.site:8080
即可访问到本地服务器了。
###配置微信服务器
由于微信服务器只能使用80或443端口,分别使用http
或https
,当给设置frps
的vhost_http_port
端口为80时,frpc
访问会有安全问题,这里我们使用nginx
反向代理到frps
服务器。
nginx配置文件:
server {
listen 80;
server_name www.findsunshine.site; #本机IP或者域名
access_log /var/log/nginx/frps_access.log;
charset utf-8;
autoindex off;
location /{
proxy_pass http://www.findsunshine.site:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
启动nginx
,我们就可以通过http://www.findsunshine.site
访问本地服务了。