4

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?

3
  • What are you using to POST? Curl might be adding an Expect header
    – larowlan
    Nov 8, 2015 at 1:04
  • I tested and used many browsers, like IE or Firefox. Neither of them got the true result. Nov 10, 2015 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, 2016 at 13:49

2 Answers 2

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

3
  • These configurations are also set, but don't answer. Apr 6, 2015 at 14:02
  • Set client_max_body_size 200M; in /etc/nginx/proxy_params;
    – arundev.me
    Apr 6, 2015 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. Apr 6, 2015 at 14:23
-1

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;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .