0

Having read a bunch of other topics similar to this one, I'm still not sure what would be best. Let's say I have a load balancer with 2 servers which have Nginx + Django, and then a separate database server and 3 storage servers with images and videos.
How do I best serve the media files from the 3 storage servers ? What I currently plan to do is keeping my 2 entry points for all the requests. A request for a media file would be authenticated there by Django and then I would use X-accel direct to proxy pass the media request to the storage servers. However, the Nginx docs state this:

When NGINX proxies a request, it sends the request to a specified proxied server, fetches the response, and sends it back to the client.

Does this mean that the load would be the same for the 2 entry point servers ? This is how I would understand it, which is not very efficient.

enter image description here

What I would like to achieve is something like this:

enter image description here

The request is authenticated by Django, the redirected towards the storage server which sends the response directly to the client. Is this possible?

I guess the most efficient way performance wise to serve media files would be to remove the app server step, like so:

enter image description here

However, this would mean that I cannot authenticate the media request with Django and have to use secure links, which is the secure link module for Nginx. How good is the security with those links?

mrj
  • 589
  • 1
  • 7
  • 17
  • Is this some sort of on-prem situation or a cloud? – AKX Apr 20 '21 at 17:56
  • Everything is cloud. – mrj Apr 20 '21 at 17:56
  • Then you'd probably be best off using that cloud's file storage solution (Amazon S3, Google Cloud Storage, Azure Blob Storage) (with presigned URLs for authentication). `django-storages` has storage providers for all of those. – AKX Apr 20 '21 at 17:59
  • @AKX I'm using OVH, which also generates a public temp URL when requested. Is this system actually secure? – mrj Apr 20 '21 at 18:36
  • 1
    Assuming the signing duration is short and everything is over HTTPS, it's pretty secure. Depends on your threat model, of course. – AKX Apr 20 '21 at 19:17

0 Answers0