FRP deployment process to achieve intranet penetration (windows)


foreword

In the previous article, we briefly introduced the load balancing and the purpose of my server. This article will introduce in detail how to use FRP to achieve intranet penetration, map the port of the business side to the load balancing server, and realize the load balancing server. Associated with the business server, you can simulate some constructions according to your own needs, and the processes are similar. All steps and instructions below are described in my own environment.


Deployment environment

  • Server: Windows 10, here you can choose various servers as the server according to the conditions. Generally, nginx is used as the server, that is, the load balancing server.
  • Client: android 10, here is to hook the signature of a treasure, encapsulated into the mobile phone selected by the interface as the business server.

Step 1: Download the required packages

  • Download address: https://github.com/fatedier/frp/releases
  • Download the corresponding version package according to your own environment and needs. For my environment and needs, I downloaded frp_0.37.1.windows_amd64.zip for the server and frp_0.37.1_linux_arm64.tar.gz for the client
    insert image description here

Step 2: Server configuration and startup

  • The configuration is as follows:
[common]
#绑定服务端IP地址
bind_addr = 0.0.0.0
#绑定服务端端口,即预留给客户端连接的通道
bind_port = 7000
#登陆后台账号
dashboard_user = admin
#登录后台密码
dashboard_pwd = 123456
#后台端口,启动成功后可通过浏览器访问如http://ip:7500
dashboard_port = 7500
#设置客户端token,对应的客户端有,也需要配置
token = dqonW98WEQW0snd0-098321*ds
  • Note: If you need more powerful or detailed configuration, you can check the detailed description of frps_full.ini in the downloaded package.
  • Startup: Open cmd, go to the decompression directory of the downloaded software package frp_0.37.1.windows_amd64.zip, execute the command ./frps -c .\frps.ini to start the frp server, and the following prompt will appear if the startup is successful:
    insert image description here

Step 3: Check whether the server configuration is successful

Open the browser to access: http:127.0.0.1:7500, which is the dashboard_port port in the above configuration file. If you can open the management page, the configuration of the service has been completed:
insert image description here
you can see the details of the bound business server here.

Step 4: Push the files needed by the client to the phone and extract them

  • 1. Push the software package to the server
    adb push ./frp_0.37.1_linux_arm64.tar.gz (package download location) /data/local/tmp (staging location on the phone)
  • 2. Enter the phone console
    adb shell
  • 3. Get the highest privilege
    su
  • 4. Enter the package temporary location
    cd /data/local/tmp
  • 5. Unzip the package
    tar -zxvf frp_0.37.1_linux_arm64.tar.gz
  • 6. Concerned files
    Server: frps, frps.ini
    Client: frpc, frpc.ini

Step 5: Client configuration and startup

  • The configuration is as follows:
[common]
#服务端的IP地址
server_addr = 172.26.11.22
#服务端的端口
server_port = 7000
#设置客户端的token,对应服务端
token = dqonW98WEQW0snd0-098321*ds
#提前连接数
pool_count = 5

[range:TBsign911]
#通信类型
type = tcp
#本地地址
local_ip = 127.0.0.1
#本地(客户端)映射端口
local_port = 6010-6020,6022,6024-6028,8134
#远程(服务端)映射端口
remote_port = 6010-6020,6022,6024-6028,8134
  • Note: If you need more powerful or more detailed configuration, you can check the frpc_full.ini description in the downloaded package
  • Start:
    ./frpc
    ./frpc -c frpc.ini
  • A prompt like the one shown indicates that all ports are successfully mapped:
    Client:
    insert image description here
    When the client connects to the server:
    Server:
    insert image description here
  • Background command: ./frpc -c frpc.ini >/data/null 2>&1 &

Step 7: Check whether the frp server client is successfully configured and can communicate

  • The management page of the server:
    If you can see all the mapped ports under Proxies->TCP, it means that the configuration is OK (tcp is the communication type configured by the client):
    insert image description here

  • For normal access, try to use the server to access a program on the mobile phone (client): for
    example, a certain treasure signature interface is deployed on a mobile phone (client) of mine, and the open port number is 8134, and then I use postman to create a A normal request is as follows:
    insert image description here

  • After using FRP to achieve intranet penetration, create a request to access the local port on the server side, and it will be automatically forwarded to the interface on the mobile phone (client):
    from the port mapping in the client configuration in step 5, we can see The ports on the mobile phone are mapped to the ports on the server: 6010-6020, 6022, 6024-6028, 8134, of which the port being signed by Taobao is 8134, which is also mapped to the server (if the port on the server is already occupied Now, it can be mapped to other ports, it does not need to be the same as the client), OK, create a POST request on the server to access the signature interface of a treasure:
    insert image description here


Finish

OK, the above is the construction process this time. In fact, the deployment process of mobile phones as business servers is similar to that of ordinary servers or cloud servers. The most important thing here is actually the FRP configuration file, which maps the port of the business server to the load balancing server, and incoming requests will be forwarded to the business server, and the load balancing server will be open to the outside world for customers to use. All requests from customers All will go through the load balancing server, and the load balancing algorithm will be allocated to the business server, and the business server will implement the business process. This article is to associate the business server with the load balancing server. Next article: Compiling haproxy with cygwin (Windows)

Guess you like

Origin blog.csdn.net/xiaoxin_OK/article/details/120772247