Configuring NGINX Access for Custom Docker Instance Folders

Configuring NGINX Access for Custom Docker Instance Folders

If you have django application with docker and nginx, where you create your own 'folder' for storage then we have to give access nginx to retrieve storage files to public.

  • If we ignored to give access to server the folder in 'nginx.conf' file then it might be show the '502 gate way error' in production server.

To resolve the issue in production server we can follow the following codes:

  • Lets assume that our own folder name is 'TestFolder' which is inside the media folder.
  • Then, we should write the following code:
 location /media/TestFolder/ {
        alias /home/app/web/media/TestFolder/;
        expires 30d;
        add_header Pragma "public";
        add_header Cache-Control "public";
    }

 

Which helps nginx to serve the folder's file to the public.