WIP: Using NGINX to serve static files
This makes it possible to serve static content more efficiently using NGINX. NGINX can serve thousands of parallel requests at the same time. It uses NGINX to serve to kinds of files:
-
/static
files necessary for running the server -
/assets
files uploaded by the users. This doesn't yet implement the any means to upload to/assets
but that should be easy, given this basis to work on.
Technical Description
NGINX runs on the same container as app
.
I have changed the container type from python:3.7
to python:3.7-alpine
,
which makes it smaller, securer and faster to build.
This means it takes little time to build and run the server,
which is a direct gain in productivity.
There are three special directories for this:
-
nginx.conf
in the root of the repo, which is mapped to/etc/nginx/nginx.conf
-
/static
in root, which is mapped to/static
folder and made accessible through the/static
route. -
user-data
named volume, which is mapped to/assets
and made available through the/assets
route. Here you upload all your files, images, etc. Although the current server really only has 300 GB of storage.
NGINX also handles SSL and encryption much more easily than gunicorn. To run this server, just execute:
$ sudo docker-compose up --build
Which will start the HTTPS Server on port 443
How to go from here
With this a the base, we can now make it possible to upload files and reference them from posts. This doesn't implement a specific method to do so, but makes most of those thinkable possible.