I am trying to access the media files using Nginx.
The file exists in the directory: /usr/src/app/backend/media/profile/c4ebe33d-7da1-4a62-bb17-8da254d69b36, where the part profile/c4ebe33d-7da1-4a62-bb17-8da254d69b36 is created dynamically.
The media root is: /usr/src/app/backend/media.
I know the file exists cause I am able to see it in the container.
This is my nginx config:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=7d use_temp_path=off;
upstream backend {
server backend:8000;
}
upstream frontend {
server frontend:3000;
}
server {
listen 80 default_server;
server_name _;
server_tokens off;
gzip on;
gzip_proxied any;
gzip_comp_level 4;
gzip_types text/css application/javascript image/svg+xml;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
client_max_body_size 100M;
location /_next/static {
proxy_cache STATIC;
proxy_pass http://frontend;
}
location /static {
proxy_cache STATIC;
proxy_ignore_headers Cache-Control;
proxy_cache_valid 60m;
proxy_pass http://frontend;
}
location /media/ {
autoindex on;
alias /usr/src/app/backend/media/;
}
location / {
proxy_pass http://frontend;
}
location /api/ {
proxy_pass http://backend;
proxy_set_header Host $http_host;
}
}
When trying to access the file I get 404. This is the link to file: http://localhost/media/profile/c4ebe33d-7da1-4a62-bb17-8da254d69b36/da258fe5-f57c-44d2-94cf-00bef250b86d.png
I tried modifying nginx, cause I think this is the reason, but without success.