1

I use nginx as a reverse proxy. Behind it is coming apache hosing foo.com . In order to upload a big file, I set post_max_size = 20M and upload_max_filesize = 20M in php.ini . But I can't upload file with size bigger than 2MB. My nginx configuration is:

server {
listen 80;
server_name  .foo.com;
if ($http_host != "www.foo.com") {
    rewrite ^ http://www.foo.com$request_uri permanent;
}
access_log /var/log/nginx/foo.access.log;
error_log /var/log/nginx/foo.error.log;

index index.php index.html;

location / {
    proxy_pass http://192.168.1.2:80/;
    include /etc/nginx/proxy_params;
    proxy_buffering off;
    chunked_transfer_encoding on;
   }
}

In addition I configured nginx.conf as following:

http {
...
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 600;
    client_max_body_size 200M;
    types_hash_max_size 2048;
    # server_tokens off;

    include fastcgi_params;
    fastcgi_read_timeout 600;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
...
}

Any ideas on how to solve the problem?

  • What are you using to POST? Curl might be adding an Expect header – larowlan Nov 8 '15 at 1:04
  • I tested and used many browsers, like IE or Firefox. Neither of them got the true result. – Mohsen Saberi Nov 10 '15 at 8:06
  • @MohsenSaberi did you try increasing nginx and PHP logging to pinpoint the reason? Also, do you receive any kind of HTTP code when the connection is cut? You could use a proxy or sniffer to know exactly what the HTTP response looks when it cuts transmission – kamihack Jul 5 '16 at 13:49
1

In nginx.conf set the max body size.

client_max_body_size 20M;

Also GoTo /etc/php5/fpm/php.ini

; Maximum size of POST data that PHP will accept.

post_max_size = 100M

; Maximum allowed size for uploaded files.

upload_max_filesize = 100M

  • These configurations are also set, but don't answer. – Mohsen Saberi Apr 6 '15 at 14:02
  • Set client_max_body_size 200M; in /etc/nginx/proxy_params; – arundev.me Apr 6 '15 at 14:17
  • Added the parameter to proxy_params. The file content is: proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 200M; But yet I can't upload file with size bigger than 2MB. – Mohsen Saberi Apr 6 '15 at 14:23
0

Add this parameters to http section of your nginx.conf:

proxy_connect_timeout       300;
proxy_send_timeout      300;
proxy_read_timeout      300;
proxy_buffer_size       512k;
proxy_buffers           32 4m;
proxy_busy_buffers_size     25m;
proxy_temp_file_write_size  10m;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.