In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Before you understand this article, please read the first two blog posts. Or you'll feel confused. This article mainly focuses on the expansion of divergent thinking and some problems encountered by this blogger on the basis of the first two articles. I hope it will be helpful to others so that you can avoid detours. Nginx Port Forwardin
If port 80 of the server is already occupied, you can use nginx to forward the port and add the following configuration:
Vim / usr/local/nginx/conf/vhost/ngrok.XXX.com.conf
The contents are as follows:
Upstream ngrok {server 127.0.0.1 keepalive 8888; # here the port should be the same as the port specified when starting the server ngrok;} server {listen 80 serverSecretname * .ngrok.XXX.com;access_log / data/wwwlogs/ngrok.XXX.com_access.log;error_log / data/wwwlogs/ngrok.XXX.com_error.log;location / {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:8888; # here the port should be the same as the port specified when starting the server ngrok. Proxy_set_header X-Nginx-Proxy true;proxy_set_header Connection "; proxy_pass http://ngrok;}}
Restart nginx
Service nginx reload
About ngrok server / usr/local/ngrok/bin/ngrokd-domain= "ngrok.XXX.com"-httpAddr= ": 8888"-httpsAddr= ": 8889"
# domain enter the NGROK_DOMAIN when the certificate was generated just now
# http and https ports can be specified by yourself. Port 80 is not used here because other programs are already occupied, and port forwarding has been configured for nginx.
# if you want to start in the background, execute the following command (there are many ways to start in the background, just select one of them)
Nohup / usr/local/ngrok/bin/ngrokd-domain= "ngrok.XXX.com"-httpAddr= ": 8888"-httpsAddr= ": 8889" > / dev/null 2 > & 1 &
# if you want to boot, add the following to rc.local. Please adjust the details according to your own situation.
Vim / etc/rc.d/rc.local
/ usr/local/ngrok/bin/ngrokd-domain= "ngrok.XXX.com"-httpAddr= ": 8888"-httpsAddr= ": 8889" > / var/log/ngrok.log & about the ngrok client
Your compiled client and server are used together, you can share your client with others to use, others can only connect to your server, other servers can not connect.
Make sure that the linux version of ngrok has execute permission
Chmod + x ngrok
In the same directory of the ngrok program, write the configuration file
Vim ngrok.cfg
The contents are as follows:
Server_addr: "ngrok.XXX.com:4443" trust_host_root_certs: falsetunnels: test: subdomain: "test" # defines the server assigned domain name prefix proto: http: 80 # mapping port Without ip default native https: 80 web: subdomain: "web" # define server assigned domain name prefix proto: http: 192.168.1.100 web 80 # mapping port You can add ip to assign tcp forwarding port to any private network mapping https: 192.168.1.100 web1 80 web1: hostname: "ngrok.XXX.com" proto: http: 80 web2: hostname: "XXX.com" proto: http: 80 ssh: remote_port: 50001 # server If this is left empty, the server assigns proto: tcp: 22 # Mapping local port 22 ssh2: # the server assigns port proto: tcp: 21
Start ngrok
. / ngrok-subdomain test-config=ngrok.cfg 80
# or
. / ngrok-config ngrok.cfg start test
# if multiple port mappings are configured in the configuration file, you can start multiple ports
. / ngrok-config ngrok.cfg start test ssh
# if there is a problem and you want to view the log locally, you can add the log parameter.
#. / ngrok-log ngrok.log-config ngrok.cfg start test
# finally, if `online` is displayed in `Tunnel Status`, it is successful.
Server firewall
Since the firewall is turned on on the server and iptables is used, the above ports need to be added to the whitelist
There are three of them, one is ngrok's own port 4443, and there are custom 8888 http ports and 8889 https ports.
Vim / etc/sysconfig/iptables
Add the following
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 4443-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 8888-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 8889-j ACCEPT
Restart iptables
Service iptables restart
Ali CVM settings
If your server is Ali Public Cloud ECS, you need to make the following settings: manage console-ESC instance-manage-this instance security group-configuration rules-create rules. Just release the three ports that the server is listening to.
Go locale installation
The installation method of yum was introduced in the previous article. This is a manual installation. Download the installation package according to your own system and download the address http://www.golangtc.com/download
Decompress directly after the download is completed.
Tar-zxvf go1.7.4.linux-amd64.tar.gz-C / usr/local
Set the environment variable, you can adjust the path according to your needs.
Vim / etc/profile
Export GOROOT=/usr/local/go
Export PATH=$PATH:$GOROOT/bin
Export GOPATH=$HOME/go
Export GOROOT_BOOTSTRAP=/usr/local/go
Make the variable effective
Source/etc/profile
Check to see if the installation is successful
Go env
Cross compilation of ngrok
Cross-compilation: to generate executable code on one platform on another.
Some people on the Internet say that when you want to compile the windows client version on the server, you need to make the following settings:
Cd / usr/local/go/src
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0. / make.bash
After I have tested it on another server, I don't have to do this. I can just compile it according to the method in the previous article.
I press the above to set up. Instead, they will report a mistake like this:
Go. / make.bash: eval: line 135: syntax error near unexpected token `(
ERROR: Cannot find / root/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree > = Go 1.4.
The reason for the error: the new version of go is not written in C, but the one before 1.4 is written in C, so you need to install 1.4 before you can compile 1.6, so install 1.4 first and then install 1.6.
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.