Large JSON file upload getting nginx 413 error
-
I'm trying to import JSON blog content into Ghost using the Ghost admin dashboard: Settings -> Labs -> Import Content
After a minute or so Ghost gives the error:
Import failed - Request is larger than the maximum file size the server allows.This seems to be down to a 413 Request Entity Too Large response from Nginx.
Is there a way to increase this limit on a per app basis or globally, temp or permanently?
The file is 137MB.
Ghost version 3.26.1 - package (v3.126.0)
-
Not sure where nginx is coming into the picture. Cloudron's reverse proxy is indeed nginx but it has no upload limits since we leave it to the app. Ghost itself has no upload limits afaik. Do you have happen to use a http proxy? Can you try uploading with a different network?
-
There is no proxy anywhere on my connection or the server. Someone else has reported this problem to me and I have found the same problem. I can try later with a 4G mobile connection but as someone else has the same issue and my internet connection is gigabit fibre I do not think it has anything to do with the connection.
-
@marcusquinn Oh, did not know that. In fact, the error message seems exactly the same - https://community.cloudflare.com/t/413-request-entity-too-large-upload-limit-100mb/97630 . So @tkd do you use Cloudflare?
-
@girish Yeah, and it's $20/month per domain for "Pro" to increase that limit.
Hence, I'm looking at a DNS Made Easy + X4B + BunnyCDN combo as an alternative.
A little more work to manage separately but the ability to control costs and features more granularly is necessary when managing a variety of domain needs but aiming for a common system among all of them.
-
Ok, thanks that helped. There are two memory related issues I can reproduce.
- Memory limit from Cloudron side: With that json import I had to at least bump up the memory limit for that app instance via the Cloudron dashboard to 1Gb temporarily
- It will still fail due to
JavaScript heap out of memory
in nodejs
Both issues will result in status code 413, which results in Ghost showing the error message
Request is larger than the maximum file size the server allows
which is not related to the actual upload size or so, but actually a processing memory requirement issue.I don't yet have a solution but just wanted to give an update here.
-
-
So the fix, with which I was successfully able to import this file is, to give the javascript engine, which is used by nodejs, more heap space:
node --max-old-space-size=4096 current/index.js
In this case allowing up to 4Gb. The issue is, I am not sure how to put this properly in the package, as this heavily depends on the set memory limit of the whole app instance.
Hopefully we can come up with a good solution later today.
-
We will make a new release which contains a env file at
/app/data/env
There the max-old-space can be set/overwriten temporarily for the import. The test json in this case worked with a 2Gb limit for me.The file can be changed using the file manger from the cloudron dashboard or webterminal. Once changed, the app has to be restarted.
Of course first update your ghost instance to latest package version 3.126.1
-
Truly heroic support! Happy to know this is covered and tested