(四)frp內(nèi)網(wǎng)穿透web服務(wù)

frp的安裝介紹

前提提交

  • 有自己的域名。

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)穿透安全配置。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容