I managed to run my Django app locally with docker compose( Django container + Nginx container) and it works fine, but when i want to run it in Azure web app for containers nginx can't find the ressources. I don't know if i should change some configuration so it can work in Azure services or i need to enable ports in azure app settings therefore my containers could communicate.
This is my nginx configuration (nginx.conf) :
upstream myapp {
server web:8000;
}
server {
listen 80;
server_name myappname.azurewebsites.net;
location / {
proxy_pass http://myapp;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /home/app/web/static/;
}
location /media/ {
alias /home/app/web/media/;
}
}
I don't know why it did work locally when i run docker compose but in azure web app nginx can't find static files.
Please let me know if I need to clarify or include anything else.
Thanks in advance.
Thank you Joseba S. . Posting your suggestion as an answer to help other community members.
Spin down the development containers:
Test:
You can also verify in the logs via
docker-compose -f docker-compose.prod.yml logs -fthat requests to the static files are served up successfully via Nginx.You can refer to Dockerizing Django with Postgres, Gunicorn, and Nginx, Cannot locate static files after deploying with docker and Nginx failing to serve django static or media files