zoukankan      html  css  js  c++  java
  • Nginx配置max_fails fail_timeout 不起作用

    1.默认配置时,http_404状态不被认为是失败的尝试。

    2.location

    location / {
                proxy_pass http://tomcatserver1;
                index  index.html index.htm;
                # proxy_next_upstream
                proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; 
                proxy_connect_timeout 7s;
                proxy_read_timeout 7s;
                proxy_send_timeout 7s;
            }

    3.配置nginx.conf文件 具体配置如下

     upstream report{                                                                                                                       
             server localhost1:18080 max_fails=10 fail_timeout=7s;                                                                                                            
             server localhost1:28080 max_fails=10 fail_timeout=7s;                                                                                                            
            server localhost2:18080 max_fails=10 fail_timeout=7s;                                                                                                             
            server localhost2:28080 max_fails=10 fail_timeout=7s;                                                                                                             
            #ip_hash;                                                                                                                              
        } 

    4.参考:https://blog.csdn.net/u011202188/article/details/88802035

    5./home/wwlocal/wwlnginx/conf/nginx.conf

    worker_processes 8;
    # worker_cpu_affinity 0001 0010 0100 1000;
    error_log  log/error.log info;
    # error_log  log/error.log debug;
    # error_log  log/error.log  notice;
    # error_log  log/error.log  info;
    pid        sbin/nginx.pid;
    worker_rlimit_nofile 102400;
    events {
        worker_connections  102400;
    }
    http {
        include mime.types;
        default_type text/plain;
        log_format main '$remote_addr $host [$time_local] $status $request_time $body_bytes_sent $request_uri $upstream_addr $upstream_status " $http_user_agent" $upstream_response_time $http_headhex $connection';
        access_log logs/access.log main;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        server_tokens off;
        keepalive_timeout 60;
        keepalive_requests 2048;
        gzip on;
        gzip_static on;
        gzip_min_length 1000;
        gzip_buffers 4 8k;
        gzip_comp_level 7;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_types text/plain application/x-javascript text/css application/xml image/jpeg image/gif image/png;
        proxy_max_temp_file_size 0;
        proxy_buffer_size 64k;
        proxy_buffers 4 64k;
        proxy_connect_timeout 1s;
        client_header_buffer_size 16k;
        large_client_header_buffers 4 32k;
        client_max_body_size 80m;
        client_body_buffer_size 60m;
        server_names_hash_max_size 1024;
        server_names_hash_bucket_size 1024;
        underscores_in_headers on;  
        #upstream wwlproxy{
        #    server 255.255.255.255:80 max_fails=10 fail_timeout=1s;
        #    server 255.255.255.255:80 max_fails=0 backup;
        #}短链后端配置请到/home/wwlocal/wwlnginx/conf/webhost.conf
        include webhost.conf;
        server {
            listen 80;
            location / {
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_redirect off;
                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://wwlproxy;
            }
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
                root html;
            }
        }
    }
    stream {
        log_format tcplog "$remote_addr [$time_local] $status $session_time $bytes_sent $bytes_received $upstream_addr $upstream_connect_time $connection";
        access_log      logs/stream.log tcplog;
        #upstream wwlconn {
        #        server 255.255.255.255:8080;
        #}长链后端配置请到/home/wwlocal/wwlnginx/conf/tcpconn.conf
        include tcpconn.conf;
        server {
            listen 8080 so_keepalive=30m::10;
            proxy_pass wwlconn;
        }
    }
    2,/home/wwlocal/wwlnginx/conf/webhost.conf
    
     
    
    upstream wwlproxy{
            server 192.168.1.10:80 max_fails=10 fail_timeout=1s;
            server 192.168.1.20:80 max_fails=10 fail_timeout=1s;
            server 192.168.1.30:80 max_fails=10 fail_timeout=1s;
            server 192.168.1.10:80 max_fails=0 backup;
            server 192.168.1.20:80 max_fails=0 backup;
            server 192.168.1.30:80 max_fails=0 backup;
            keepalive 128;
    }
  • 相关阅读:
    Best Time to Buy and Sell Stock
    Remove Nth Node From End of List
    Unique Paths
    Swap Nodes in Pairs
    Convert Sorted Array to Binary Search Tree
    Populating Next Right Pointers in Each Node
    Maximum Subarray
    Climbing Stairs
    Unique Binary Search Trees
    Remove Duplicates from Sorted Array
  • 原文地址:https://www.cnblogs.com/hixiaowei/p/14210454.html
Copyright © 2011-2022 走看看