我的Nginx,在每2次尝试中执行一次proxy_pass

这是我的Nginx代码,它将请求“/ nt”反向代理到另一个应用程序。 但它每2次尝试只有一次工作:

events {

  worker_connections 32000;
  use epoll;
  accept_mutex on;
  multi_accept on;
}

http {

  include mime.types;
  default_type application/octet-stream;

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  reset_timedout_connection on;
  gzip off;
  access_log off;
  keepalive_timeout 0;
  client_max_body_size 20m;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  access_log /var/log/openresty/access.log;
  error_log /var/log/openresty/error.log;

  real_ip_header X-Forwarded-For;

  limit_conn_zone $binary_remote_addr zone=perip:5m;
  limit_req_zone $binary_remote_addr zone=one:5m rate=100r/s;
  limit_req_zone $binary_remote_addr zone=phplimit:10m rate=3r/s;

  server {

    listen 80 default_server;
    listen [::]:80 default_server;
    limit_conn perip 5;
    limit_req zone=one burst=20 nodelay;
    limit_req_status 444;
    limit_conn_status 444;
    root /usr/local/openresty/nginx/html/default;
    index index.html index.htm;

    location /nt {

      proxy_buffering off;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_connect_timeout 10;
      proxy_send_timeout 30;
      proxy_read_timeout 30;
      proxy_http_version 1.1;
      limit_req_status 444;
      proxy_pass http://$proxy;
    }
  }
}

这是正确尝试时反向到应用程序的请求标头:

{
    host: 'NGONX反向代理服务器IP''x-forwarded-for': 'CLIENT IP',
    connection: 'close''cache-control': 'max-age=0''upgrade-insecure-requests': '1''user-agent':
     'Mozilla/5.0(Windows NT 10.0; Win64; x64)AppleWebKit/537.36(KHTML,like Gecko)Chrome/75.0.3770.100 Safari/537.36',
    accept:
     'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,应用程序/signed-exchange;v=b3''accept-encoding''gzip,deflate''accept-language': 'en-US,en;q=0.9'
}

这是错误尝试时反向到应用程序的请求标头:

{
    host: '127.0.0.1:3000',#我的应用程序URL
    connection: 'close''cache-control': 'max-age=0''upgrade-insecure-requests': '1''user-agent':
     'Mozilla/5.0(Windows NT 10.0; Win64; x64)AppleWebKit/537.36(KHTML,like Gecko)Chrome/75.0.3770.100 Safari/537.36',
    accept:
     'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,应用程序/signed-exchange;v=b3''accept-encoding''gzip,deflate''accept-language': 'en-US,en;q=0.9'
}

为什么会发生这种情况?

点赞