在自己的电脑上配置好了项目,并且可以用localhost进行访问,但是外网想要访问怎么办呢?这时候frp就起作用了!
工具:frp安装包、公网ip地址、公网绑定好的域名。
公网ip的价格大约1000块/月,用此方式建网站的话,成本太高。
1.首先下载frp包并进行解压。下载地址:https://github.com/fatedier/frp/releases
注意:版本一定要下载最新的,否则frp允许过程中会因为版本问题报错!
2.下载完成后,文件内容如图:
只要对frpc.inc以及frps.ini进行配置即可。一个是客户端配置文件,另一个是服务端配置文件。
3.先对服务端文件进配置。打开frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080// http访问端口号
- [common]
- bind_port = 7000
- vhost_http_port = 8080// http访问端口号
[common]
bind_port = 7000
vhost_http_port = 8080// http访问端口号
4.对客户端进行配置。打开frpc.ini
[common]
server_addr = 1.2.3.4 //已经购买的外网ip地址
server_port = 7000 //默认7000
token = abc1234567//认密码,默认为abc1234567
[ssh]//ssh访问配置
type = tcp
local_ip = 127.0.0.1
local_port = 22 //访问端口
[web]// http访问配置信息
type = http
local_ip = 127.0.0.1
local_port = 8088 //本地项目访问端口号
custom_domains = www.tianqiweiqi.com //已经注册好的域名
- [common]
- server_addr = 1.2.3.4 //已经购买的外网ip地址
- server_port = 7000 //默认7000
- token = abc1234567//认密码,默认为abc1234567
- [ssh]//ssh访问配置
- type = tcp
- local_ip = 127.0.0.1
- local_port = 22 //访问端口
- [web]// http访问配置信息
- type = http
- local_ip = 127.0.0.1
- local_port = 8088 //本地项目访问端口号
- custom_domains = www.tianqiweiqi.com //已经注册好的域名
[common]
server_addr = 1.2.3.4 //已经购买的外网ip地址
server_port = 7000 //默认7000
token = abc1234567//认密码,默认为abc1234567
[ssh]//ssh访问配置
type = tcp
local_ip = 127.0.0.1
local_port = 22 //访问端口
[web]// http访问配置信息
type = http
local_ip = 127.0.0.1
local_port = 8088 //本地项目访问端口号
custom_domains = www.tianqiweiqi.com //已经注册好的域名
5.配置完成后,在浏览器中输入www.tianqiweiqi.com即可对项目进行外网访问。