首页 > 系统相关 >Nginx配置max_fails fail_timeout 不起作用 - stub_status - 调试 nginx --with-debug

Nginx配置max_fails fail_timeout 不起作用 - stub_status - 调试 nginx --with-debug

时间:2023-06-26 12:06:49浏览次数:63  
标签:status fails http log max server nginx proxy timeout

0.stub_status

configure arguments: --prefix=/usr/local/tengine --with-http_realip_module --with-http_gzip_static_module --with-pcre --with-http_stub_status_module --with-http_ssl_module --add-module=/opt/nginx-goodies-nginx-sticky-module-ng

[root@slave1 conf.d]# cat myserver.conf
  server {
  
    listen 80;
    client_max_body_size 4G;

   
    server_name example.com 129.211.117.78 www.example.com;

    keepalive_timeout 5;

    access_log  /var/log/nginx/access.log ;
    error_log  /var/log/nginx/errors.log warn;
    location / {
      proxy_pass http://app_server1;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Host $http_host;

      proxy_redirect off;

    }

location /media  {
    alias /opt/sudjango/nginxdjango/media;
  }
 
  location /static {
    alias /opt/sudjango/nginxdjango/static;
  }
  location /ngx_status
  {
   stub_status on;
#   access_log off;
   allow all;
  }
    error_page 500 502 503 504 /500.html;
    location = /500.html {
      root /path/to/app/current/public;
    }
  }
[root@slave1 conf.d]#

 

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; 
       ##如果后端的服务器返回502、504、执行超时等错误,自动将请求转发到upstream负载均衡池中的另一台服务器,实现故障转移。

            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.参考

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

 3.调试 nginx

用到 --with-debug ,待写。

4、如何调试 location#

可以通过在不同 location 里添加 access_log 来调试。

5、如何调试 rewrite#

rewrite_log on; 开启 nginx 日志

设置 error_log 的 level 是 notice

https://www.zhihu.com/question/30255532

 

用一个例子来演示会更加清晰



标签:status,fails,http,log,max,server,nginx,proxy,timeout
From: https://blog.51cto.com/u_13747193/6552818

相关文章

  • Nginx-PHP优化设置 + lnmp调优的关键影响因素 + php-fpm + nginx返回码 + tcp调优 +
    最大文件描述符Linux内核本身有文件描述符最大值的**,你可以根据需要更改:系统最大打开文件描述符数:/proc/sys/fs/file-max临时性设置:echo1000000>/proc/sys/fs/file-max永久设置:修改/etc/sysctl.conf文件,增加fs.file-max=10000002、用户级设置vi/etc/security/limits.confhttp......
  • elk 入门 - 分析nginx日志 + json格式 + 有调试的意识 + elk7.2.0
    1.本次采用的一台主机,将所有的软件安装一台上进行测试工作。2.安装部署:https://blog.51cto.com/hwg1227/22999953.简单调试输出rubydebuginput{file{path=>"/usr/local/log_test/*/*/*.log"start_position=>"beginning"}}output{e......
  • 配置文件 proxy_set_header -发往后端服务器的请求头---- nginx日志设置级别调试技巧
    http{includemime.types;default_typeapplication/octet-stream;sendfileon;#tcp_nopushon;#keepalive_timeout0;keepalive_timeout65;server_tokensoff;log_formatmain'$remote_addr-$remote_user[$time_local]......
  • Nginx 根据请求参数代理到指定网址
    1、参考nginx中将某一个请求的路径重定向到其它网址nginx:[emerg]unknowndirective"if($request_uri"in2、小坑if与($间需要有空格。判断请求路径中,是否包含/adminif($request_uri~'/admin'){return404;}3、配置location/xxxxx/client/register{......
  • MacOs Docker nginx.conf 配置
    `server{listen8089;server_namelocalhost;client_max_body_size120M;#php容器项目地址root/var/www/html/shop;indexindex.phpindex.htmlindex.htm;location/{#try_files$uri$uri//index.php?s=$uri&$args;}......
  • Git-status-log-add-commit
    gitstatus查看修改文件有哪些gitstatus-s等效于gitstatus--shortgitlog......
  • macbook m1 使用 brew 安装 nginx + 多版本 php
    目录macbookm1使用brew安装nginx+多版本php安装多个php版本1.配置php仓库2.安装多版本php3.配置php-pfm的端口4.启动php-pfm服务5.切换php-cli命令行的版本安装nginxmacbookm1使用brew安装nginx+多版本php在FastAdmin开发是,可能会用到多个p......
  • 使用 Debian、Docker 和 Nginx 部署 Web 应用
    前言本文将介绍基于Debian的系统上使用Docker和Nginx进行Web应用部署的过程。着重介绍了Debian、Docker和Nginx的安装和配置。第1步:更新和升级Debian系统通过SSH连接到服务器。更新软件包列表:sudoaptupdate升级已安装的软件包:sudoaptupgrade第2步......
  • 服务器与本地资源同步,在ubuntu自建git库,使用nginx远程http访问
    xshell在linux与windows之间传文件虽然方便,但使用git才能真正实现资源同步。为实现服务器与本地资源同步,在ubuntu服务器端自建git库。使用 git-http-backend 搭建git服务的原理都是类似的,主要是利用web服务器(apache/nginx)进行用户认证,并将用户信息传递给CGI程序 ......
  • Nginx反向代理&记录用户IP地址企业案例
    反向代理机器节点:lb0110.0.0.30#lb01是反向代理服务器(包括负载均衡的功能)www0110.0.0.40www0210.0.0.50【演示反向代理功能】 图片解读:使用客户端机器www01,访问负载均衡lb01(反向代理),看到了www01,www02页面信息在www01服务器上检测客户端信息,发现请求是10.0.0.3......