frp内网穿透配置多个端口

frp内网穿透配置多个端口

一、frp项目的官方中文文档地址

https://github.com/fatedier/frp/blob/master/README_zh.md

二、部署准备

1、公网ip(云服务器一台)

2、内网服务器一台(个人电脑)

3、域名(可选)

4、frp(分为客户端和服务器端)

三、搭建web服务(ssh等其他服务参考官方文档)

1、服务器端搭建

服务器搭建在公网上,以下操作为阿里云服务器

1)下载对应的frp在阿里云服务器上

a.先查看linux版本信息

cat /proc/version

结果

Linux version 3.10.0-1062.4.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org)

b.创建文件夹

cd /home
mkdir frp
cd frp

c.下载frp

wget https://github.com/fatedier/frp/releases/download/v0.31.2/frp_0.31.2_linux_386.tar.gz

d.解压文件

tar xvf frp_0.31.2_linux_386.tar.gz 

e.进入文件

cd frp_0.31.2_linux_386
2)配置frp

a.编辑配置文件frps.ini

vim frps.ini 

内容

[common]
bind_port = 7000
vhost_http_port = 8080   

b.wq保存退出,启动服务

./frps -c ./frps.ini

c.出现以下结果,说明启动成果

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Coj8Wx1q-1582513021518)(/Users/bobwang/Library/Application Support/typora-user-images/image-20200210224331237.png)]

3)nginx配置

nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    server {
        listen 80;
        server_name  127.0.0.1; # 改为自己的域名,没域名修改为127.0.0.1
        charset utf-8;
        client_max_body_size  50000m;
        location /{
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
}

启动nginx

2、内网搭建客户端(MAC平台)

1)下载跟服务器端版本一致的frp

frp_0.31.2_darwin_amd64.tar.gz

2)解压后进入文件配置frps.ini

cd frp_0.31.2_darwin_amd64
vim frpc.ini

我的配置为

[common]
server_addr = xxx.xxx.xxx.xxx # 服务器ip
server_port = 7000

[web1]
type = http
local_port = 8080
custom_domains = xxx.xxx.xxx.xxx # 服务器ip
locations = / # eg:http://xxx.xxx.xxx.xxx/yolo/test
[web2]
type = http
local_port = 8081
custom_domains = xxx.xxx.xxx.xxx # 服务器ip
locations = /ocr # eg:http://xxx.xxx.xxx.xxx/yolo/test

3)wq退出保存,启动服务

./frpc -c ./frpc.ini

三、本地启动django服务,并设置ALLOWED_HOSTS

四、开机自启,参考一下文章

简书:https://www.jianshu.com/p/5f7e71121a4f

个站:https://www.newlearner.site/2018/12/12/frp-mac.html

知乎:https://zhuanlan.zhihu.com/p/45445979

CSDN:https://blog.csdn.net/qq_42443261/article/details/91048585

  • 2
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值