{"id":193,"date":"2013-08-21T22:00:43","date_gmt":"2013-08-21T22:00:43","guid":{"rendered":"https:\/\/reviewsignal.com\/blog\/?p=193"},"modified":"2013-08-22T05:01:31","modified_gmt":"2013-08-22T05:01:31","slug":"wordpress-nginx-uploads-413-request-entity-too-large","status":"publish","type":"post","link":"https:\/\/reviewsignal.com\/blog\/2013\/08\/21\/wordpress-nginx-uploads-413-request-entity-too-large\/","title":{"rendered":"WordPress + Nginx + Uploads = 413 Request Entity Too Large"},"content":{"rendered":"<p><i>Happy <a href=\"https:\/\/reviewsignal.com\/blog\/category\/wordpress-wednesday\/\">WordPress Wednesday<\/a>! The day of the week dedicated to talking about <a href=\"http:\/\/wordpress.org\">WordPress<\/a>.<\/i><\/p>\n<p>Or sad, if you had to deal with the problem I ran into today while working on our WordPress blog. I wanted to upload some larger pictures and got a cryptic '<span style=\"color: #ff0000;\">HTTP Error<\/span>'.<\/p>\n<p>Let me explain the architecture I am running here so that this makes sense. I run Nginx as a reverse proxy and caching server in front of Apache. Nginx forwards traffic to apache when it needs to and serves everything from memory when it doesn't (which is incredibly fast).<\/p>\n<p>Back onto the problem, the error message isn't helpful. I did what I normally do, look at the error log. I didn't see anything in the apache log or the nginx log.<\/p>\n<p>What I did discover was by opening Chrome's developer tools and watching the Network tab I could see the file uploads were failing. They were red and had a status code of<span style=\"color: #ff0000;\"> 413: Request Entity too Large<\/span>.<\/p>\n<p>Now I know my httpd.conf (Apache's config file) was set to accept files as big as these images.<\/p>\n<p>So now I had to look at the nginx.conf. What I discovered was nginx's default setting is 1 megabyte. So I added this line to my http configuration within nginx:<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\">client_max_body_size 20m;<\/pre><\/td><\/tr><\/table><\/div>\n\n<p>According to the <a href=\"http:\/\/wiki.nginx.org\/HttpCoreModule#client_max_body_size\">documentation<\/a> you can put it in http, server, and location.<\/p>\n<p>A quick<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\">service nginx restart<\/pre><\/td><\/tr><\/table><\/div>\n\n<p>And all was well in the world.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Happy WordPress Wednesday! The day of the week dedicated to talking about WordPress. Or sad, if you had to deal with the problem I ran into today while working on our WordPress blog. I wanted to upload some larger pictures and got a cryptic &#8216;HTTP Error&#8217;. Let me explain the architecture I am running here [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":207,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[47],"tags":[59,60,57,58,48],"_links":{"self":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/193"}],"collection":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":8,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/193\/revisions\/208"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/media\/207"}],"wp:attachment":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}