Connecting Django to a web server
We must have a gateway service that manages the static content. We will use Caddy for its simplicity.
Caddy is configured with a flat file named Caddyfile. We must create it and add the following content:
http://hello.localhost {
    root * /usr/src/app/
    @notStatic {
      not path /static/* /media/*
    }
    reverse_proxy @notStatic django:8000
    file_server
}
http://webmail.localhost {
    reverse_proxy mailhog:8025
}
With the first line, http://hello.localhost, we indicate the domain that we will use. As we are in a development environment, we will indicate the http protocol instead of https. Next, with root * /usr/src/app/ and file_server, we’re telling Caddy to expose static files (images, CSS files, JavaScript files, and so on) because that’s not Django’...