Below is my nginx conf I am using (nginx is a docker container)- Nginx is used as a proxy server to all backend api servers. When I am tried to upload file I am getting error if size is greater then 1 MB. Tried all possible solution given but cloudn't resolve. Any help would be useful.
server {
listen 80;
server_name abcd.dev;
#rewrite ^/(.*)/$ /$1 permanent;
charset utf-8;
keepalive_timeout 300s;
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
client_body_in_file_only clean;
client_body_buffer_size 10M;
client_max_body_size 10M;
sendfile on;
send_timeout 300s;
proxy_buffering off;
proxy_request_buffering off;
proxy_buffer_size 10M;
proxy_buffers 32 4m;
proxy_busy_buffers_size 10m;
proxy_max_temp_file_size 1024m;
proxy_temp_file_write_size 10m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_set_header HOST $host;
#X-Forwarded-Proto header gives the proxied server information about the schema of the original client request (whether it was an http or an https request).
proxy_set_header X-Forwarded-Proto $scheme;
#The X-Real-IP is set to the IP address of the client so that the proxy can correctly make decisions or log based on this information.
proxy_set_header X-Real-IP $remote_addr;
#The X-Forwarded-For header is a list containing the IP addresses of every server the client has been proxied through up to this point.
#In the example above, we set this to the $proxy_add_x_forwarded_for variable.
#This variable takes the value of the original X-Forwarded-For header retrieved from the client and adds the Nginx server's IP address to the end.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
error_page 404 /custom_404.html;
location = /custom_404.html {
root /usr/share/nginx/html;
internal;
}
error_page 500 502 503 504 /custom_50x.html;
location = /custom_50x.html {
root /usr/share/nginx/html;
internal;
}
location / {
location ~ ^/(uploads/|vendor/|images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
proxy_pass http://ui-service;
}
if ($domain) {
set $args $args&nethumUrl=$domain;
proxy_pass http://ui-service$uri$is_args$args;
}
proxy_pass http://ui-service$uri$is_args$args;
}
...........
}
I am able to upload any files which is less then 1MB but bigger files not getting uploaded. Getting below error -
error 2017/03/02 06:52:37 [error] 38#38: *89 recv() failed (104: Connection reset by peer) while reading response header from upstream
What is your php.ini setting on upload_max_filesize? Also try to add client_max_body_size 10M; in your http directive (in /etc/nginx/nginx.conf), as well as in the location directive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With