1、安装准备依赖库
yum -y install pcre-devel openssl openssl-devel gcc gcc-c++ make
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 \
--with-stream \
--with-http_realip_module \
--with-stream_realip_module \
--with-stream_geoip_module
3、编译和安装
make
make install
4、配置
vim /usr/local/tengine/config/nginx.conf
upstream cluster1 {
# simple round-robin
server 192.168.8.197:8222;
server 192.168.8.197:8223;
# interval:向后端发送的健康检查包的间隔
# rise(rise_count): 如果连续成功次数达到rise_count,服务器就被认为是up
# fall(fall_count): 如果连续失败次数达到fall_count,服务器就被认为是down
# timeout: 后端健康请求的超时时间
# type=http:健康检查包的类型,发送HTTP请求,通过后端的回复包的状态来判断后端是否存活。
# check_http_send:配置http健康检查包发送的请求内容。
# check_http_expect_alive :指定HTTP回复的成功状态,默认认为2XX和3XX的状态是健康的
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;
}
}
5、启动nginx
/usr/local/tengine/sbin/nginx
6、访问健康状态
http://192.168.200.158:81/status
如下图所示
最后修改于 2020-11-10 15:13:42
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

