nginx upload client_max_body_size issue

前端 未结 3 1221
滥情空心
滥情空心 2020-11-30 19:22

I\'m running nginx/ruby-on-rails and I have a simple multipart form to upload files. Everything works fine until I decide to restrict the maximum size of files I want upload

3条回答
  •  星月不相逢
    2020-11-30 19:33

    Does your upload die at the very end? 99% before crashing? Client body and buffers are key because nginx must buffer incoming data. The body configs (data of the request body) specify how nginx handles the bulk flow of binary data from multi-part-form clients into your app's logic.

    The clean setting frees up memory and consumption limits by instructing nginx to store incoming buffer in a file and then clean this file later from disk by deleting it.

    Set body_in_file_only to clean and adjust buffers for the client_max_body_size. The original question's config already had sendfile on, increase timeouts too. I use the settings below to fix this, appropriate across your local config, server, & http contexts.

    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    
    client_max_body_size 300M;
    
    sendfile on;
    send_timeout 300s;
    

提交回复
热议问题