I have 2 RoR web applications hosted on 2 different servers. For one particular page, the request is served from the second application. For rest of the pages, the request is served from the main application. Nginx settings for the main application
location /customer/help/ {
proxy_pass http://second-application:3020/help_and_support/;
}
location /assets/ {
proxy_pass http://second-application:3020/assets/;
}
This worked fine until yesterday. Now, /customer/help/
page is not loading properly. In firefox it shows a blank page, in chrome, it loads partially and console shows an error
net::ERR_INCOMPLETE_CHUNKED_ENCODING
After debugging I found that issue might be with image data sent over API. My second app calls an API to get images and displays them on page
<% url_with_binary_data = "data:image/" + "jpeg" + ";base64," + u.photo_url.to_s %>
<%= image_tag(url_with_binary_data, :class => "userpic") %>
API code to get the image
photo_url: Base64.encode64(u.photo.file.read).gsub("\n", '')
You might want to check if the user that is running the Nginx worker owns the directory
/var/lib/nginx
.I've learned that when you give a response too big for Nginx, it uses this directory to write as a working directory for temporary files. If the worker process cannot access it, Nginx will terminate the transmission before it completes, thus the error INCOMPLETE_CHUNKED_ENCODING.
Bumped into this issue on AWS and found that adding a few proxy_buffer directives to the site config file fixed the issues:
For me the solution was enable
proxy_max_temp_file_size
For me, the solution was what DfKimer recommended, but instead of
/var/lib/nginx
it was/var/cache/nginx
.