關於 frp+nginx實現內網穿透+共用埠
首先 frps 和 frpc 對比
[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 80
vhost_https_port = 8443
dashboard_port = 7500
dashboard_pwd = admin
[web01]
type = http
auth_token = admin
custom_domains = www.wxqyhcs.com#通過frps所在服務端域名進行訪問
==================================
# [common] is integral section
[common]
server_addr = 139.196.98.33#服務端ip
server_port = 7000#對應frps的埠7000
# Resolve your domain names to [server_addr] so you can use http://web01.yourdomain.com to browse web01 and http://web02.yourdomain.com to browse web02
[web01]
type = http
local_ip = 127.0.0.1
local_port = 8000 #frps通過域名穿透進來,預設訪問本地的8000埠
auth_token = admin
custom_domains = www.wxqyhcs.com
www.wxqyhcs.com----->127.0.0.1:8000
============
再看nginx
server {
listen 8000;
server_name www.wxqyhcs.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location /rzhy/ {
proxy_pass http://127.0.0.1:8081/rzhy/;
root html;
index index.html index.htm;
}
location /mrjc/ {
proxy_pass http://127.0.0.1:8083/mrjc/;
root html;
index index.html index.htm;
}
}
}
nginx實現 8081 8083兩個tomcat共用本地8000
綜上所述,連貫起來理解:
frp通過www..com--->內網127.0.0.1:8000--->
根據專案字尾是什麼,跳轉到對應的專案----nginx
這裡要注意 nginx的serverName