In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Preface
With the development of the Internet, both web services and mobile APP are increasingly integrated with third-party payments (Alipay, Wechat, UnionPay). Usually, as a service provider, after the payment is successful, there will be a back-end callback URL to notify whether the caller has made the payment successfully. The URL must be a public network environment and can be accessed. However, in the actual development and testing environment, we generally develop in the intranet, so it is a troublesome thing to pay for testing.
Intranet penetration
At this time, we need intranet traversal service to solve the problem that third-party services cannot be called back. Let's take a brief inventory of those popular intranet traversal technologies.
Ngrok
Ngrok is a reverse proxy by establishing a secure channel between a public endpoint and a locally running Web server. Ngrok can capture and analyze traffic on all channels for later analysis and playback (Baidu encyclopedia).
Advantages: easy to use, Docker containerized, easy to configure, supported by each platform, and you can also build your own servers.
Disadvantages: ngrok is an open source program, the official website service is abroad, and the speed of visiting abroad is slow at home. 1.7 + is no longer open source, and charging is the driving force for sustainable development.
There are also corresponding ngrok services such as natapp, frp, nat123 port mapping, Intranet, peanut shell and so on. We will not introduce them one by one here. Those who are interested can Google on their own. After all, today's protagonist is Ngrok.
In the following picture, let's take a look at the penetration process of Ngrok:
Environment description
Image of Linux (centos7.4), Nginx, Docker and hteen/ngrok Docker of CVM, and one domain name for registration
Installation instructions
Docker installation instructions are omitted here, please install Docker yourself.
Get ngrok image: when docker pull hteen/ngrok starts, we need to mount the host directory (E.g / data/ngrok) to the container's / myfiles directory for the first time. It will generate binaries and CA certificate sudo docker run-- rm-it-e DOMAIN= "ngrok.52itstyle.com"-v / data/ngrok:/myfiles hteen/ngrok / bin/sh / build.sh in the / data/ngrok directory.
The following prompt appears for a successful installation (omitting the intermediate process):
Generating RSA private key, 2048 bit long modulus..+++..+++e is 65537 (0x10001) Generating RSA private key 2048 bit long modulus..+++..+++go get-tags' release'-d-v ngrok/...go install-tags' release' ngrok/main/ngrokbuild ok!
Client and server are generated in the / data/ngrok/bin directory:
Bin/ngrokd server bin/ngrok linux client bin/darwin_amd64/ngrok osx client bin/windows_amd64/ngrok.exe windows client starts Ngrok server
Since ngrok uses ports 80 and 443 by default, we use Nginx service for forwarding and access the Docker container through port mapping (see docker-compose.yml configuration).
Docker run-idt-- name ngrok-server\-v / data/ngrok:/myfiles\-p 8082 data/ngrok:/myfiles 80\-p 4432 data/ngrok:/myfiles 443\-p 4443 DOMAIN='ngrok.52itstyle.com' hteen/ngrok / bin/sh / server.sh
After startup, you need to add two reverse proxy configurations to nginx.conf (HTTPS request self-configuration):
Server {listen 80; server_name ngrok.52itstyle.cn * .ngrok.52itstyle.com; location / {proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8082; }} configure DNS resolution
After the service is started, to run normally, we need to add two A records to the CVM (replace it with our own IP address):
Start Ngrok client
First download the clients in each environment from the data/ngrok/bin directory.
Windows environment
First create a ngrok.cfg configuration file:
Server_addr: "ngrok.52itstyle.com:4443" trust_host_root_certs: false
Use the cmd command to change to the corresponding directory and execute the following command:
Ngrok.exe-config ngrok.cfg-subdomain doc 192.168.1.125purl 4999
If the following interface appears, the installation is successful:
Linux environment
It is strange that the following error has been reported when running under linux, but it is not clear what the reason is. If you know it, you would like to let us know:
-bash:. / ngrok: / lib/ld-musl-x86_64.so.1: bad ELF interpreter: without that file or directory note, the firewall needs to open port 4443, otherwise the successful Wechat QR code payment callback requires domain name authentication (only one URL can be entered in the backend). This is a bit of a hole!
Finally, I recommend a detailed code case of Alipay, Wechat and UnionPay: https://gitee.com/52itstyle/spring-boot-pay
Referenc
Https://hub.docker.com/r/hteen/ngrok/
Https://hteen.cn/docker/docker-ngrok.html
Https://github.com/hteen/docker-ngrok
Https://gitee.com/52itstyle/spring-boot-pay
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.