frp實現內外網穿透訪問內網web服務和接口

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;
          }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章