1、安装准备依赖库

 yum -y install pcre-devel openssl openssl-devel

2、编译安装

 ./configure --prefix=/usr/local/tengine --without-http_upstream_keepalive_module \
 --add-module=modules/ngx_backtrace_module \
 --add-module=modules/ngx_debug_pool \
 --add-module=modules/ngx_debug_timer \
 --add-module=modules/ngx_http_concat_module \
 --add-module=modules/ngx_http_footer_filter_module \
 --add-module=modules/ngx_http_proxy_connect_module \
 --add-module=modules/ngx_http_reqstat_module \
 --add-module=modules/ngx_http_slice_module \
 --add-module=modules/ngx_http_sysguard_module \
 --add-module=modules/ngx_http_trim_filter_module \
 --add-module=modules/ngx_http_upstream_check_module \
 --add-module=modules/ngx_http_upstream_consistent_hash_module \
 --add-module=modules/ngx_http_upstream_dynamic_module \
 --add-module=modules/ngx_http_upstream_dyups_module \
 --add-module=modules/ngx_http_upstream_keepalive_module \
 --add-module=modules/ngx_http_upstream_session_sticky_module \
 --add-module=modules/ngx_http_user_agent_module
 

3、配置

 vim /usr/local/tengine/config/nginx.conf

 upstream cluster1 {
       # simple round-robin
        server 192.168.8.197:8222;
        server 192.168.8.197:8223;

        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;
    }

     server {
        listen 81;
        server_name  192.168.200.158;
       location /status {
                check_status;
                access_log off;
        }
        location = /stub_status {
                stub_status on;
        }
        location / {
               proxy_next_upstream http_502 http_504 error timeout invalid_header;
               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://cluster1;
        }
     }

4、启动nginx

 /usr/local/tengine/sbin/nginx

5、访问健康状态

http://192.168.200.158:81/status

如下图所示

 

最后修改于 2020-11-10 15:13:42
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇