frp的安裝介紹
- 已經(jīng)在第一節(jié)文章有介紹請(qǐng)參考 (一)frp內(nèi)網(wǎng)穿透ssh登錄內(nèi)網(wǎng)ip服務(wù)器
前提提交
- 有自己的域名。
frp 內(nèi)網(wǎng)穿透web服務(wù)配置
這里以centos7下的java后端服務(wù)為例
首先安裝nginx
- yum install nginx
啟動(dòng)命令 systemctl start nginx
停止命令 systemctl stop nginx
- 啟動(dòng)已經(jīng)編寫的好的java后端程序
nohup java -jar service.jar &
假設(shè)java后端程序端口為8080
在nginx的conf.d 目錄(/etc/nginx/conf.d/)添加service.conf文件配置內(nèi)容如下
upstream xxxservie {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name www.xxx.com;
server_tokens off;
location / {
proxy_pass http://xxxservie;
}
}
- 重啟nginx
nginx -s reload
公網(wǎng)服務(wù)器frp
- frps.ini 新增vhost_http_port配置
# frps.ini
[common]
bind_port = 7000
dashboard_port = 7500
# dashboard 用戶名密碼,
dashboard_user = admin
dashboard_pwd = XXXXXX
vhost_http_port = 80
kill frps進(jìn)程
啟動(dòng)
./frps -c ./frps.ini
內(nèi)網(wǎng)服務(wù)器frp
- frpc.ini 新增web配置如下.
[common]
server_addr = x.x.x.x # 公網(wǎng)機(jī)器的ip地址
server_port = 7000 # frp服務(wù)端端口地址
[ssh]
type = tcp
local_ip = 127.0.0.1 #內(nèi)網(wǎng)機(jī)器ip地址
local_port = 22 # 內(nèi)網(wǎng)機(jī)器的ssh服務(wù)端口
remote_port = 6000 #通過公網(wǎng)訪問的ssh端口
[mysql]
type = tcp
local_ip = 127.0.0.1 #內(nèi)網(wǎng)機(jī)器ip地址
local_port = 3306 # 內(nèi)網(wǎng)機(jī)器mysql端口
remote_port = 1006 # 通過公網(wǎng)訪問的mysql端口
[web]
type = http
local_port = 80
custom_domains = www.xxx.com
kill frpc進(jìn)程
啟動(dòng)
./frpc -c ./frpc.ini
訪問www.xxx.com 就可以正常訪問了。
下章
- 配置內(nèi)網(wǎng)穿透安全配置。