Tengine 2.2.0 Compilation, Installation, Boot-up, Reverse Agent Configuration and Health Check

Keywords: Nginx Linux Windows yum

Tengine 2.2.0 Compilation, Installation, Boot-up, Reverse Agent Configuration and Health Check

tengine is an open source project based on nginx initiated by taobao. nginx throughput is relatively high, fast and stable, and reverse proxy and load balancing using nginx is the most common. This article describes how to compile and install under Linux (centos), set up nginx boot-up self-start, configure reverse proxy and configure health check. Official address

1. Download tengine

  • download

The next one is to download it directly using Linux or download it with windows and upload it to linux, but this is more troublesome.

wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
  • decompression
tar -zxvf tengine-2.2.0.tar.gz 

2. Compile and Install

  • Install compile dependencies
yum -y install gcc gcc-c++ autoconf automake

yum -y install openssl-devel pcre-devel zlib-devel
  • Compile tengine

    To enter the tengine decompression directory, you must enter the directory after decompression, responsible for the back can not continue.

cd tengine-2.2.0

Check the compilation environment. Note: - Preix is followed by your nginx installation path

./configure --prefix=/home/msoft/tengine/ \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_concat_module \
--with-pcre
If this step does not indicate lack of dependencies, the check passes. If lack of dependencies, please see the installation of dependency libraries above. Next is the compilation.
make && make install

So far, it has been compiled and installed. If you don't want to use it another day, you can delete the installation directory directly. Then test the installation results. After executing the startup command, the default port of nginx is 80. windows can directly access the ip of linux. Under linux, curl localhost or wget localhost is used.

//Enter your installation directory
cd /home/msoft/tengine/sbin

//Startup file for executing nginx
./nginx

3. Join the system service and set up boot-up

  • Create startup file
    click nginx startup file Download startup files, may be because of the encoding problems of Windows Linux can not recognize, so use windows to download, and then use Notepad and other software to open. Then Linux enters cd/etc/init.d/, and creates the file vi nginx with the vi editor. Copy all of the notes directly into the vi editor.
    Note: This section must remember to modify your installation path and configuration path.
//This is the address of the startup file of your computer nginx.
nginx="/home/msoft/tengine/sbin/nginx"
//nginx configuration file address
NGINX_CONF_FILE="/home/msoft/tengine/conf/nginx.conf"

Then save the file, and you will find that the file nginx is not green, indicating that there is no execute permission.

  • Configuration boot-up

Give executive authority

chmod 755 nginx

Add this file to the system service

chkconfig --add nginx

Set up boot start

chkconfig nginx on

Check to see if the addition was successful

chkconfig --list nginx

Start, stop, reload

service nginx start|stop|reload

4. Configuring Reverse Agents

Enter your nginx installation directory

cd /home/msoft/tengine/conf/
vi nginx.conf

Configuration of reverse proxy, directory structure as shown below, you can configure more than one, only one in the case.

upstream myback {
        server localhost:8080;
        server 192.168.1.110:8080;
    }
location / {
            proxy_pass        http://myback ;
            proxy_set_header  X-Real-IP  $remote_addr;
            client_max_body_size  100m;
        }

Note: This block directly configures the ip: port, and can also be forwarded to a specific module, in the figure / yasaka, which is a module of configuration. At that time, the browser can be proxyed to the specific back-end server by directly entering the following address.

http://yasaka.iask.in/

http://yasaka.iask.in/yasaka

5. Configuration of health check-ups

tengine has its own health check, add the following configuration, configuration structure to see the picture
This is the case address http://yasaka.iask.in/status

location /status {
            check_status;
        }

Then add them to the reverse proxy, and those back-end servers need health checks.

check interval=3000 rise=2 fall=5 timeout=1000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;

Note: Remember to change lines here, otherwise you will parse errors.


6. Summary

This paper introduces the compilation and installation of tengine (nginx), including boot-up, reverse proxy and health check. Specific details or which module would like to go deeper, please refer to the official documents, I will not repeat the wheel here.

Posted by LoganK on Thu, 13 Jun 2019 13:42:14 -0700