net::ERR_CONTENT_LENGTH_MISMATCH error while uploading image to IPFS

I have a simple webapp with a form to upload an image to IPFS. I am using ipfs-js-api to add the file to IPFS. Everything works well on my dev box. In production, I am using nginx. Since I can’t directly communicate with my IPFS daemon (localhost), I have a proxy set up so the frontend can communicate with the daemon through However, when I upload a file, I get the error:

TypeError: network error
Uncaught (in promise) TypeError: network error

My code looks like this:

function saveImageOnIpfs(reader) {
  return new Promise(function(resolve, reject) {
    const buffer = Buffer.from(reader.result);
    .then((response) => {
    }).catch((err) => {

My nginx configuration is:

    location /ipfs/ {
            proxy_pass http://localhost:5001/;
            proxy_http_version 1.1;
            proxy_set_header Host $http_host;    
            proxy_set_header   X-Real-IP         $remote_addr;
            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

Can someone help me with this issue?

I’m not sure about the code, but shouldn’t the URL be something like below instead (note the difference in where the port is specified)?

You need to proxy to localhost:8080 . I have also made a docker image that makes ipfs easy to deploy/use. Check it out: IPFS in Docker with HTTPS

I have the proxy forward for path /ipfs. So, it would be ipfs/:443

Good idea, I should have just used docker instead of struggling with this. I will go the docker route, thanks!

Just as an example of how easy it is to use docker:
I just now googled for container as a service providers, and i found (i dont understand the name, but the service seems to work just fine).
I made a free account (signed in with github, didnt require any payment info).
I deployed my docker image.
And here is the result:

A ipfs gateway/node deployed in like 3 minutes!