/ Ubuntu

Solving the maximum file size error on Ghost + NGINX

I ran into an error when uploading a awesome Mesmerising Waterfall - Picture in a post today. The error stated something on the lines of:

The image you uploaded was larger than the maximum file size your server allows.

This blog runs Ghost and is served of NGINX. I had difficulty figuring out the size limitation was being set by Ghost or by NGINX.

A little research revealed that file uploads were limited to the default maximum size of NGINX at 1 MB as specified in Module ngx http core module.
My file size was 1.2 MB and hence the error!

I increased the size to 2m by editing the NGINX config file /etc/nginx/nginx.conf and adding a line client_max_body_size 2m; in the http section.

Reload the NGINX config file using:

sudo service nginx reload

The file upload should work like magic! And yeah! Enjoy the picture!

picture

BTW ... This config change applies to all the virtual hosts serving off NGINX. I am pretty sure that this can be limited to particular hosts, but lets save that for another day!