nginx的upstream配置backup和check方法

server {
    listen                  80;
    server_name             ocean.xxxx;
    access_log              /app/tengine_log/logs/ocean.xxxx.gelk.access.log intranethttps;    # 校验此日志格式是否在主配置文件里存在
    error_log               /app/tengine_log/logs/ocean.xxxx.gelk.error.log error;
    
    proxy_set_header        Host                $host;
    proxy_set_header        X-Real-IP           $remote_addr;
    proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;

    location    / {
                  proxy_headers_hash_max_size 51200;
                   proxy_headers_hash_bucket_size 6400;
                   proxy_set_header X-Real-IP $remote_addr;
                   proxy_set_header X-Forwarded-For $remote_addr;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $host;
                   proxy_connect_timeout 180;
                   proxy_read_timeout 180;
                   proxy_send_timeout 180;
                   proxy_redirect off;
                   proxy_pass http://ocean.live.cn;
    }

}

upstream ocean.live.cn {
    # None
    server 192.168.1.8:8081 max_fails=3 fail_timeout=10 weight=1;
    server 192.168.1.8:8081 max_fails=3 fail_timeout=10 weight=1 backup;
    check interval=3000 rise=2 fall=3 timeout=2000 type=http;
    check_http_send "GET /xxxx/config/status HTTP/1.1\r\nHost: \r\n\r\n";
    check_http_expect_alive http_2xx http_3xx;
}

posted @ 2022-11-01 11:19  心愿666  阅读(840)  评论(0编辑  收藏  举报