title: Nginx & PHP-FPM - download size is limited to ~3MB
body: <p>I have a CSV Download, with Docker, Nginx and PHP-FPM, everything runs fine, until downloads
  gets larger then 2-3 MB. The generated CSV files exists in the php container (in my tmp 
  directory /var/www/symfony/var/tmp/... and looks fine), but Nginx cant serve them. 
  Nginx error logs shows this</p>
  
  <blockquote>
    <p>2019/05/09 12:09:29 [crit] 7#7: *747 open()
    "/var/tmp/nginx/fastcgi/2/07/0000000072" failed (13: Permission
    denied) while  reading upstream, client: 172.18.0.1, server: ,
    request: "GET /catalog-download HTTP/1.1",  upstream:
    "fastcgi://172.18.0.3:9001", host: "localhost", referrer:
    "<a href="http://localhost/catalog" rel="nofollow noreferrer">http://localhost/catalog</a>"</p>
  </blockquote>
  
  <p>Looks like my csv file is not there and Nginx or somebody should have moved them to the
  Nginx tmp folder.</p>
  
  <p>There are some post about Nginx download problems, but most of them
  have problems with 300MB and larger. So I think my problem is different. Downlaods
  are fine, but are limited &lt; ~2-3MB.</p>
  
  <p>Nginx Config is</p>
  
  <pre><code>user www;
  
  worker_processes 4;
  pid /run/nginx.pid;
  
  events {
      worker_connections  2048;
      multi_accept on;
      use epoll;
  }
  
  http {
      server_tokens off;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 15;
      types_hash_max_size 2048;
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
      access_log off;
      error_log off;
      gzip on;
      gzip_disable "msie6";
      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;
      open_file_cache max=100;
      client_body_temp_path /tmp 1 2;
      client_body_buffer_size 256k;
      client_body_in_file_only off;
      client_max_body_size 50M;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>upstream php-upstream {
      server php:9001;
  }
  
  server {
      listen 80;
      server_name mydomain.tk;
      server_tokens off;
  
      location /.well-known/acme-challenge/ {
          root /var/www/certbot;
      }
  
      location / {
          return 301 https://$host$request_uri;
      }
  }
  
  server {
      listen 443 ssl;
      server_name mydomain.tk;
      server_tokens off;
  
      ssl_certificate /etc/letsencrypt/live/mydomain.tk/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/mydomain.tk/privkey.pem;
  
      include /etc/letsencrypt/options-ssl-nginx.conf;
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
  
      root /var/www/symfony/public;
  
      location / {
          try_files $uri /index.php$is_args$args;
      }
  
      location ~ ^/.+\.php(/|$) {
          fastcgi_pass php-upstream;
          fastcgi_split_path_info ^(.+\.php)(/.*)$;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
          fastcgi_param DOCUMENT_ROOT $realpath_root;
          fastcgi_read_timeout 240;
          internal;
      }
  
      location ~ \.php$ {
          return 404;
      }
  
      error_log /var/log/nginx/error.log;
      access_log /var/log/nginx/access.log;
  }
  </code></pre>
  
  <p>PHP FPM config is</p>
  
  <pre><code>[symfony]
  user = www
  group = www
  listen = 0.0.0.0:9001
  pm = dynamic
  pm.max_children = 20
  pm.start_servers = 2
  pm.min_spare_servers = 1
  pm.max_spare_servers = 3
  catch_workers_output = yes
  request_terminate_timeout = 240
  </code></pre>
  
  <p>changes in php.ini are</p>
  
  <pre><code>date.timezone = 'Europe/Berlin'
  memory_limit = 512M
  
  opcache.memory_consumption = 256
  opcache.max_accelerated_files = 20000
  opcache.validate_timestamps = 1
  realpath_cache_size = 4096K
  realpath_cache_ttl = 600
  
  post_max_size = 50M
  upload_max_filesize = 50M
  max_execution_time = 240
  sendmail_path = "/usr/bin/msmtp -t"
  </code></pre>
  
  <p>But at the moment, I dont think PHP-FMP has an issue, because csv files exists. It has something to do with missing file in the '/var/tmp/nginx/fastcgi/' folder. </p>
  
  <p>I would be very happy about any help. </p>