Server responded with 0 code Error - Files Bigger than 2MB I have been getting "Server responded with 0 code" error as I upload a big file. Files Bigger than 2MB
My server is on Forge. ( I contacted with Forge team)
I have an upload form. It is working on DropZoneJs
I increased the php limits ( I restarted nginx I can see in phpinfo )
post_max_size=100M
upload_max_filesize=100M
I also played with Nginx settings by adding
client_max_body_size 200M;
But I have been still getting the same error. I don't know what else to do?
I also increased the max_file_upload_size from Forge.
This could still be because of max execution time.
// php.ini
max_input_time 1800
max_execution_time 1800
memory_limit = 200M
// nginx.conf: (right along the other 'fastcgi_' directives)
fastcgi_read_timeout 1800;
There might be more usefull errors in nginx's error log.
If this doesn't work, please post your nginx config file for the domain and any included config files so we can have a look. I believe the error is in between your nginx and php.
I didn't work @lostdreamer_nl
Where exactly should we put client_max_body_size 200M; in Forge nginx conf?
It is a little bit dynamic nginx file
server {
listen 80;
server_name .exampe.tc;
location = / {
return 301 https://www.example.com/;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
root /home/forge/example.com/public;
index index.html index.htm index.php;
charset utf-8;
include forge-conf/example.com/server/*;
location = /favicon.ico {
access_log off; log_not_found off;
}
location = /robots.txt {
access_log off; log_not_found off;
}
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/example.com/before/*;
fastcgi_read_timeout 14400;
server {
proxy_connect_timeout 14400;
proxy_send_timeout 14400;
proxy_read_timeout 14400;
send_timeout 14400;
client_max_body_size 200M;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .example.com;
if ($http_host = example.com) {
rewrite (.*) https://www.example.com;
}
root /home/forge/example.com/public;
# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/example.com/330472/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/330472/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'dfdf';
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/example.com/server/*;
location / {
fastcgi_read_timeout 14400;
client_max_body_size 200M;
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico {
access_log off; log_not_found off;
}
location = /robots.txt {
access_log off; log_not_found off;
}
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 14400;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/example.com/after/*;
check your dropzone.js setup , it may also has a limit
Did you restart php-fpm ?
@SNaRe remove all fastcgi_* and client_max_body_size parameters and replace both your .php blocks with this one:
location ~ \.php$ {
client_max_body_size 200m;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 14400;
include fastcgi_params;
}
After the change, restart nginx or reload it's config
sudo service nginx restart
// or
sudo service nginx reload
You're not going to post big files to none php files anyway, and the fast-cgi options are only needed when the request gets forwarded to php.
Have you checked the nginx and php error logs? I have only seen these errors when there was either a timeout in php, or a timeout in nginx.
Please sign in or create an account to participate in this conversation.