1

NGINX 入口控制器在哪里存储临时文件?

这是我收到的消息,我很确定它将文件存储在附加到我的一个 pod 的卷上:

2021/09/27 20:33:23 [warn] 33#33: *26 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 10.42.1.0, server: _, request: "POST /api/adm/os/image HTTP/1.1", host: "vzredfish.cic.shidevops.com", referrer: "https://vzredfish.cic.shidevops.com/setting"

但是当我进入该位置/var/cache/nginx/client_temp时,什么都没有。

我也检查了入口控制器 pod,那里也有另一个。

我想知道如何解决我们遇到的问题。我正在尝试将文件直接上传到 pod 内存,但它首先将其上传到临时位置。

谢谢您的帮助。

达尼洛

4

2 回答 2

1

间接回答您的问题似乎有一些方法可以跳过代理缓冲以实现将文件直接上传到 pod 内存的目标,我在这里找到了一篇有趣的文章,请查看禁用代理缓冲部分。

于 2021-09-28T16:22:00.457 回答
0

我要感谢 Jakub Siemaszko 的指点,这是部分解决方案。

我们的应用程序部署在一个 k8s 集群中,我们在其中一个 pod 中有一个 nginx 控制器和一个 nginx 实例。我遇到的问题与 pod 中的 nginx 而不是控制器有关(我正在更改控制器中的指令和键)

在 pod 内部的 nginx 中,我必须更改 nginx.conf 并将以下内容添加到 HTTP 和位置

http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;
client_max_body_size 25000M;
proxy_buffering off;
proxy_ignore_client_abort on;
proxy_read_timeout 3600;
proxy_http_version 1.1;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

sendfile        off;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

server {
    listen 80 default_server;

    server_name _;

    root /usr/share/nginx/html;
    index index.html;


    location /api {
        return 302 /api/;
    }
    location /api/ {
        proxy_pass http://backend:3000/;
    }
    location /downloads {
        autoindex on;
    }
    location / {
      try_files $uri $uri/ /index.html;
      proxy_read_timeout 3600;
      proxy_http_version 1.1;
      proxy_connect_timeout 3600;
      proxy_send_timeout 3600;
      fastcgi_send_timeout 3600;
      fastcgi_read_timeout 3600;
    }
}

include /etc/nginx/conf.d/*.conf;
}

这修复了 504 错误(我仍然看到 499,但它能够完成大文件的上传)。

至于临时文件的位置,这仍然是一个谜,但我们不再需要监控了

于 2021-09-30T18:41:57.113 回答