Home > Applications & Tools > Big Data to Tomcat Behind Nginx

Big Data to Tomcat Behind Nginx

October 5th, 2015 Leave a comment Go to comments

In a Web application I created, I need to upload some data to a Java Servlet for further processing. I wish JavaScript could be more powerful so that I can process everything in the front end, but I could not find a good JavaScript library for the job.

Everything works well until some big changes got in – it stopped working sometimes and the pattern is not quite consistent. Initially I thought it was because of long time processing at the server side.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

It turned out it’s not the case later when I have more to look into it later. From the browser console in developer tools, I found the following print out.

Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)

It’s clear that the server rejected the big data. Because my tomcat server runs behind Nginx, it’s not clear which server caused it. A quick look at the tomcat access log showed that there is no URL for the server. So it’s most like that Nginx caused the problem.

With that in mind, a quick Internet search with keyword with Nginx and above error message got me many articles. The solution is actually quite simple: add the following line inside the server section in the /etc/nginx/nginx.conf file as follows:

client_max_body_size 10M;

Now the Nginx will allow 10M in the request body – a limit that is good enough for my task.

With the change of configuration, the Nginx server must be restarted using the following the command:

# systemctl restart nginx
  1. October 18th, 2015 at 03:32 | #1

    Hi! If you set client_max_body_size to 0 the system stops checking the body size.

  2. October 20th, 2015 at 03:05 | #2

    Thanks a lot Serhii, will give it a try!

  1. No trackbacks yet.