In WeChat development, a server with a domain name is required as a trusted server for the backend. This brings a lot of trouble to development and debugging, and the solution is to use intranet penetration tools so that development machines in the intranet can also have externally accessible domain names. Of course, there are already some intranet penetration services that are either free or paid online and can be used directly. This article describes the use of the open source project frp to build a direct intranet penetration service.
In order to complete the actual list of this article, you need to have a server that can be accessed on the Internet, which can be purchased from Amazon, Digitalocean or other cloud service providers, and the price is not expensive. If you need to use your own domain name for intranet penetration, you can also purchase another domain name and complete the necessary certifications.For the convenience of later description, assume that:
Server IP is: 173.178.10.45
Domain name is: examples.net
Server OS: ubuntu 18.04
Client OS: Windows 10
Download frp Server
Download frp from Offical Website, Choose frp_0.33.0_linux_amd64.tar.gz。
You can also execute the following command on ubuntu terminal:
1 | wget https://github.com/fatedier/frp/releases/download/v0.33.0/frp_0.33.0_linux_amd64.tar.gz |
After the download is complete, unzip it and you can see that the directory contains the executor and configuration sample files of the server side (frps) and the client (frpc). To avoid confusion later, you can delete all frpc files.
Setup frp Server
- Copy frps into /usr/bin
1 | sudo cp frps /usr/bin |
- Create a folder, name it to /etc/frp
1 | sudo mkdir /etc/frp |
- Copy frps_full.ini file into /etc/frp and remame it to frps.ini
1 | sudo cp frps_full.ini /etc/frp/frps.ini |
- Create a folder, and name it to /var/frp, it will be used to store the log.
1 | sudo mkdir /var/frp |
- Base your need,edit the configuration file: /etc/frp/frps.ini
In this article, we only modify the following line:
1 | bind_port = 1500 |
bind_port - The port used to communicate with the client is consistent with the client’s settings
vhost_http_port - The http port of frps server
vhost_https_port - The https port of frps server
dashboard_port - frps server has a web admin console,it’s the port of admin console
dashboard_user - The user of admin conosle
dashboard_pwd - The password of amdin user
token - The token for the connections between frps and frpc
Note: You need to modify the above configuration information according to the situation of your environment
And comment out the last two plugins
1 | # [plugin.user-manager] |
- Copy the frps.service file in the systemd directory in the installation package to /var/systemd/system:
1 | sudo cp systemd/frps.service /var/systemd/system |
- Startup frps Server
1 | sudo systemctl start frps |
You can use the status subcommand to check the startup and operation of the frps service
1 | sudo systemctl status frps |
If there are no problems with the installation, you should see output similar to the following
1 | ● frps.service - Frp Server Service |
- Set boot startup
1 | sudo systemctl enable frps |
Install frp client
Because the client is running on Windows 10, download the file from the official website frp_0.33.0_windows_amd64.zip
After extracting, you can see the executable file of frpc, which is the client program.
Create a new file (text file) for a frpc .ini
The following configuration information:
1 | [common] |
where server_port and server-side configuration items bind_port for, the token corresponds to the server-side token.
Now, you can then start the frp client, executing:
1 | frpc.exe -c frpc.ini |
After startup, the development environment on the startup machine, such as the Spring Boot project in IDEA, runs on port 8080 by default.
Set DNS Service
In the DNS management interface, set up an A record for DNS, which in the case is set to
1 | api.examples.net 173.178.10.45 |
Once set up, you can access it in a browser
1 | http://api.examples.net:1500 |
Set up multiple web services
Only modifications need to be made in the client’s configuration:
1 | [web] |
Note: Custom_domains need to be different