nginx 如何处理延迟的 HTTPS 数据包/请求

nginx 如何处理延迟的 HTTPS 数据包/请求

我有一个客户端调用位于 nginx 代理后面的 Web 服务。他们的总请求时间可能长达 7-8 秒,但上游请求不到 1 秒。

我很好奇,但在文档中找不到,延迟请求是如何处理请求的?例如,如果我在 5 秒内收到标头但未收到正文,nginx 是否会等到收到完整的 HTTPS 请求后再将请求发送到上游目的地?

这是我的 nginx.conf 配置,非常原始。这是净化版:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  log_format apm '"$time_local" client=$remote_addr '
                 'method=$request_method request="$request" '
                 'server_name=$server_name '
                 'request_length=$request_length '
                 'status=$status bytes_sent=$bytes_sent '
                 'body_bytes_sent=$body_bytes_sent '
                 'referer=$http_referer '
                 'user_agent="$http_user_agent" '
                 'upstream_addr=$upstream_addr '
                 'upstream_status=$upstream_status '
                 'request_time=$request_time '
                 'upstream_response_time=$upstream_response_time '
                 'upstream_connect_time=$upstream_connect_time '
                 'upstream_header_time=$upstream_header_time';

  access_log  /var/log/nginx/access.log  apm;

  sendfile            on;
  tcp_nopush          on;
  tcp_nodelay         on;
  keepalive_timeout   65;
  types_hash_max_size 2048;
  server_names_hash_bucket_size 64;

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

  server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate     ssl/cert.crt;
    ssl_certificate_key ssl/cert.key;

    include conf.d/*.conf;

    location / {
      # Reject requests with unsupported HTTP method
      if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|DELETE)$) {
        return 405;
      }

      proxy_pass https://example.com;
    }
  }
}

相关内容