首页 > 其他分享 >Tengine 主动式后端服务器健康检查功能 ngx_http_upstream_check_module

Tengine 主动式后端服务器健康检查功能 ngx_http_upstream_check_module

时间:2022-11-30 13:34:44浏览次数:36  
标签:status http module server upstream check

本文使用的版本:Tengine-2.3.3

在 Tengine 2.3.3 中 ngx_http_upstream_check_module 默认是不包含的,所以编译配置的时候需要手动添加上去

./configure --add-module=modules/ngx_http_upstream_check_module
make

make 过后就可以在 objs 目录下找到 nginx 文件

check

    upstream cluster1 {
        # simple round-robin
        server 192.168.0.1:80;
        server 192.168.0.2:80;

        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;
    }
	
	
    upstream cluster2 {
        # simple round-robin
        server 192.168.0.3:80;
        server 192.168.0.4:80;

        check interval=3000 rise=2 fall=5 timeout=1000 type=http;
        check_keepalive_requests 100;
        check_http_send "HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n";
        check_http_expect_alive http_2xx http_3xx;
    }

该模块生效范围是 upstream 中,上面的配置文件就是 每3s检查一次,5次失败->down 2次成功->up down后不再转发请求

check_status

    server {
        listen 80;

        location /1 {
            proxy_pass http://cluster1;
        }

        location /status {
            check_status;
        }
    }

通过 check_status 命令显示服务器的健康状态页面,支持的格式有: html、csv、 json。默认类型是html。

/status?format=html
/status?format=csv
/status?format=json

标签:status,http,module,server,upstream,check
From: https://www.cnblogs.com/manastudent/p/16938123.html

相关文章

  • 检测到目标url存在http host头攻击漏洞
      修复建议对Host字段进行检测Nginx,修改ngnix.conf文件,在server中指定一个server_name名单,并添加检测。Apache,修改httpd.conf文件,指定ServerName,并开启UseCanonica......
  • Nginx12 openresty使用lua-resty-http模块
    1简介在lua中操作http请求有两种方式第一种方式:使用通过ngx.location.capture 去方式实现第二种方式:lua-resty-http,是用于访问外部Http资源,外部web服......
  • java Http请求工具类
    importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.JSONObject;importlombok.extern.slf4j.Slf4j;importjavax.net.ssl.*;importjava.io.*;importj......
  • Vue3 项目中使用setup()函数报错,script setup cannot contain ES module exports
    问题​Vue3项目中使用setup()函数,代码如下<scriptsetup>import{useStore}from"../stores/store.js";exportdefault{setup(){conststore......
  • pip Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not
      #解决方案 把…\anaconda3\Library\bin加入到系统环境变量即可。总是提示SSL有问题,然而只是SSL就在bin里边,所以没有生效。主要参考:https://github.com/conda/co......
  • 一个有趣的nginx HTTP 400响应问题分析
    背景之前在一次不规范HTTP请求引发的nginx响应400问题分析与解决中写过客户端query参数未urlencode导致的400问题,当时的结论是:对于query参数带空格的请求,由于其不符合HT......
  • 使用 Hypercorn HTTP/2 ASGI 部署 FastAPI
    AnotherASGIwebserverthatsupportsHTTP/2andHTTP/3specifications我已经介绍了很多关于FastAPI的教程,其中服务器部署了Uvicorn,一个快速的ASGIWeb......
  • 使用socket实现http服务端
    #encoding=utf-8importreimportsocket#接收消息的方法defrecv_msg(tcp_socket,recv_data):requests=recv_data.splitlines()print(requests)......
  • .NET6之MiniAPI(二十二):HttpClient
    说明:本篇不是说明HttpClient怎么使用,而以分享在asp.netcoreminiapi框架下,HttpClient的引入和使用方式。我们在业务开发中,免不了调用三方的服务,这时就会用到Htt......
  • .NET6之MiniAPI(二十二):HttpClient
    说明:本篇不是说明HttpClient怎么使用,而以分享在asp.netcoreminiapi框架下,HttpClient的引入和使用方式。我们在业务开发中,免不了调用三方的服务,这时就会用到Htt......