Serve /content/ routes with X-Sendfile #373
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
The
/download/
route handler tries to redirect mod downloads to the CDN here (_cfg("cdn-domain")
ishttps://spacedock.info/content/
):SpaceDock/KerbalStuff/blueprints/mods.py
Lines 549 to 552 in ae68684
The idea is that the
https://spacedock.info/content/
URLs should be handled by a fast server with access to the storage, what we've been calling AW (Apache Web Server).Problem
CDN handling of downloads is disabled in the server config for reasons that nobody remembers (and turning it on temporarily produced unexplained timeouts and 502 statuses):
So the
/content/
request comes back to the backend here:SpaceDock/KerbalStuff/blueprints/anonymous.py
Lines 45 to 50 in ae68684
And the gunicorn backend is handing out big files, as not intended.
But there is yet another better method for sending files which SD already supports: Apache's XSendFile module:
SpaceDock/KerbalStuff/blueprints/mods.py
Lines 555 to 566 in ae68684
This only happens for
/download/
routes, if you set_cfg('use-x-accel')
to nginx or apache and don't set_cfg("cdn-domain")
.Changes
Now if you set
_cfg('use-x-accel')
it will also be used for/content/
routes. This should make them work better because the files will be sent by Apache instead of by gunicorn.