frp外網服務端
修改frps.init配置
[common]
# 服務器端監聽客戶端連接請求的端口
bind_port = 7000
# 服務器端監聽http請求的端口
vhost_http_port = 8088
使用nohup ./frps -c frps.init > /dev/null 2>&1 & 命令,讓frp服務端在後臺掛起運行
frp內網客戶端
修改frpc.init配置
[common]
server_addr = xx.xx.xx.xx(外網ip)
server_port = 7000
[web]
type = http
local_ip = (內網服務器ip)
# 轉發到nginx監聽的端口
local_port = 80
custom_domains = xx.xx.xx.xx(外網ip,和server_addr的相同)
使用nohup ./frpc -c frpc.init > /dev/null 2>&1 & 命令,讓frp客戶端在後臺掛起運行
內網nginx配置
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ^~ /xxx(解析的路徑){
proxy_pass http://xxx.xxx.xx.xx/xxx(轉發的內網地址);
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_redirect off;
}