In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Description
Before you understand this article, it is best to read the previous article:. Recently, if the company wants to develop the official account of Wechat, it needs to solve the problem of port 80 mapping. in order to be stable and reliable, it has to build its own ngrok server. Ngrok is a reverse proxy software written in go language, which realizes intranet penetration by establishing a secure channel between public endpoints and locally running Web servers. Ngrok captures and analyzes traffic on all channels for later analysis and playback.
Environment and conditions
Server Centos6.8_x64+windows10_x64
A server with public network ip
Domain name is resolved to the server. Take the domain name ngrok.XXX.com as an example here.
With regard to domain name resolution, if your domain name is dedicated for this purpose, you can turn on universal resolution to this server. If your primary domain name is already in use, you only need to resolve a secondary domain name to this server and turn on the pan-resolution of the secondary domain name. I choose the second one, as shown in the following picture. Of course, you don't have to do pan-parsing, or you can add records in the local hosts file.
Step 1 of installation. Install the dependency package yum-y install zlib-devel openssl-devel perl hg cpio expat-devel gettext-devel curl curl-devel perl-ExtUtils-MakeMaker hg wget gcc gcc-c++ git II. Install the go language environment
You can choose yum installation, I choose yum installation
Yum install-y golang
You can also install it manually and download the address http://www.golangtc.com/download
After downloading the installation package, decompress it directly and configure the environment variables.
Compile ngrok3.1 download ngrok source code and set variables
Cd / usr/local/
Git clone https://github.com/inconshreveable/ngrok.git
Export GOPATH=/usr/local/ngrok/
Export NGROK_DOMAIN= "ngrok.XXX.com"
Cd / usr/local/ngrok
3.2 generate a self-signed certificate, and ngrok encrypts the connection for ssl. Openssl genrsa-out rootCA.key 2048openssl req-x509-new-nodes-key rootCA.key-subj "/ CN=$NGROK_DOMAIN"-days 5000-out rootCA.pemopenssl genrsa-out server.key 2048openssl req-new-key server.key-subj "/ CN=$NGROK_DOMAIN"-out server.csropenssl x509-req-in server.csr-CA rootCA.pem-CAkey rootCA.key-CAcreateserial-out server.crt-days 5000 copy the certificate file to the specified location
Cp rootCA.pem assets/client/tls/ngrokroot.crt
Cp server.crt assets/server/tls/snakeoil.crt
Cp server.key assets/server/tls/snakeoil.key
Servers need to be modified at home, but not abroad.
Vim / usr/local/ngrok/src/ngrok/log/logger.go
Log "github.com/keepeye/log4go"
3.3.Compilation of server and linux client, GOOS and GOARCH can refer to go env
Cd / usr/local/ngrok/
GOOS=linux GOARCH=amd64
Make clean
Make release-server release-client
After execution, a bin folder is generated in the current directory, which contains ngrokd and ngrok files
Where the bin/ngrokd file is the server program and the bin/ngrok file is the client program (note that GOOS is specified as
64-bit linux, so this file cannot be run on other platforms such as mac or win, and how to cross-compile is explained below)
3.4 Cross-compile client Windows client
Cd / usr/local/ngrok/
GOOS=windows GOARCH=amd64
Make release-client
MAC client
Cd / usr/local/ngrok/
GOOS=darwin GOARCH=amd64
Make release-client
Client Profil
Server_addr: "ngrok.XXX.com:4443"
Trust_host_root_certs: false
IV. Start the service
/ usr/local/ngrok/bin/ngrokd-domain= "$NGROK_DOMAIN"-httpAddr= ": 80"
Background operation
Setsid / usr/local/ngrok/bin/ngrokd-domain= "$NGROK_DOMAIN"-httpAddr= ": 80"
After starting the service, the default will enable the monitoring of 8050443. Of course, you can specify ports for ports 80 and 443, just start the service as follows
Bin/ngrokd-domain= "ngrok.XXX.com"-httpAddr= ": 8888"-httpsAddr= ": 8889"
Open the client
Ngrok-config=ngrok.cfg-subdomain=test 80
The successful startup has the following effect
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.