Score:0

nginx not serving static files after adding app to docker-compose

be flag

I have an app (blog) made with Python and Django. Using docker-compose I've managed to deploy it to a Digital Ocean droplet.

The Docker stack includes a Postgres db nginx, nginx-proxy and the nginx-acme companion for SSL. The app works fine in production.

Then I wanted to add an app for tracking usage, called Umami, with its Postgres DB. I've managed to add it to the same docker-compose stack. Both apps seem to be working, but nginx now fails (sometimes) to serve the static content.

I assume that this has to be related to the setting of nginx, so I'm sharing my setting in order to get some guidance.

Checking the logs of nginx and nginx-proxy with docker logs couldn't get any relevant data about what is wrong.

upstream my_app{
    server django:8000;
}

server {
    listen 80;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://my_app;
   }

    location /static/ {
        autoindex off;
        alias /home/app/web/staticfiles/;
    }

    location /media/ {
        autoindex off;
        alias /home/app/web/media/;
    }
}


server {
  listen 80;
  server_name umami.mypersonalserver.online;

  location / {
    proxy_pass http://localhost:3000;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Would you guys give me any hints?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.