Serving Files with Django

This video features Jochen Wersdörfer at DjangoCon Europe 2021 in Online.

Serving Files with Django
0:40:43
Published July 31, 2021
825 views

The fairly new support for real async views (since Django 3.1) opened up a lot of new possibilities. I was so excited about them that I wrote a longish blog post about the topic:
Django 3.1 Async (https://wersdoerfer.de/blogs/ephes_blog/django-31-async/)

This article was also published on paper in a german developer magazine:
Django wird asynchron (https://kiosk.entwickler.de/entwickler-magazin/entwickler-magazin-6-2020/django-wird-asynchron/)

Back then I had trouble to come up with a compelling use case for those new async views. But now I believe file serving is one of them. Usually you would use nginx in front of your Django application servers, a CDN or just S3 / another object store. But let's face it: This will add another layer of architectural complexity and authentication/authorization will be a real PITA. And some things might get a lot easier with pure Django file serving - let's assume I want to know how long people listened to my podcast delivered via http live streaming on average. If the media file was delivered via Django, it would be possible to log those numbers directly in the App. Otherwise you would have to calculate them from aws access log files or something like that (good luck with that).

So, using nginx will probably be still faster and you won't be able to saturate 100Gbit/s. But maybe you don't need to and Django alone is already fast enough. Until june I probably have some benchmarks to prove it or a story about an embarrassing failure :).

Summary

Serving files directly from a Django application server can work well, but concurrency depends on how the server handles blocked file reads. Jochen Wersdörfer benchmarks synchronous Gunicorn workers, threads, asynchronous workers, and an ASGI-based approach, showing that processes can serve concurrent downloads only by consuming substantial memory, while async I/O and gevent achieve high concurrency with fewer resources. He contrasts this with standard approaches such as WhiteNoise, Nginx, object storage, and CDNs, and explains the trade-offs for large files, private files, testing, security, and dynamically transforming downloads.

Key takeaways

  • Blocking file reads tie up synchronous workers, so serving many simultaneous downloads requires roughly one worker per active client.
  • Processes and threads can provide concurrency, but processes use much more memory and neither approach is as lightweight as asynchronous coroutines.
  • An asynchronous Django file response can use asynchronous file reads, but Django’s standard WSGI handling must be adapted; an ASGI server is needed when application code itself must await asynchronous operations.
  • For simple assets, WhiteNoise with a CDN or a dedicated web server is usually appropriate, while user-uploaded files should generally live in object storage rather than the application server’s filesystem.
  • Private files should not be protected merely by obscure URLs; X-Accel-Redirect-style handoffs or signed URLs can work, but they add infrastructure and testing complexity.
  • Geven can provide a relatively simple high-concurrency option under WSGI, especially when file requests are routed separately from normal application traffic.

Summarised automatically from the transcript.

Chapters

  1. 0:00 Django File-Serving Benchmarks Introduction to the talk and the benchmark setup for testing whether Django can saturate a gigabit connection while serving files.
  2. 5:29 Concurrency Benchmark Results Analysis of why the initial process-based server serves downloads sequentially rather than concurrently, followed by the improved asynchronous results.
  3. 8:33 Asynchronous Django File Responses How an asynchronous file response and changes to Django’s handler enable nonblocking file reads and concurrent delivery.
  4. 11:35 Processes, Threads, and Async I/O Comparison of processes, threads, and coroutines as strategies for handling many simultaneous file requests.
  5. 17:50 Established File-Serving Architectures When to use WhiteNoise, a CDN, a dedicated web server, or object storage for static and user-uploaded files.
  6. 20:08 Private File Authorization Security trade-offs of serving private files through Django, Nginx, CDNs, signed URLs, and internal redirect headers.
  7. 23:12 Dynamic Delivery and CDN Economics Potential uses for application-level file serving, including dynamic podcast insertion, and the cost trade-offs of CDNs for large files.
  8. 27:47 Choosing a Concurrency Strategy Conclusions on matching the serving approach to the application’s requirements, including cases that require ASGI and async views.
  9. 28:34 gevent File Serving Using gevent workers with the traditional WSGI interface to serve files concurrently, including a possible load-balancer split.
  10. 31:10 Questions Audience discussion about worker separation, throughput, X-Sendfile, testing, private URLs, and caching.

Questions this talk answers

Can Django serve files fast enough to saturate a gigabit connection?

Yes. In the benchmark, Django served 125 ten-megabyte files and saturated the gigabit link, but the standard process-based setup served only a few downloads concurrently rather than sharing bandwidth evenly.

Discussed at 4:41

How can I make Django serve files asynchronously and with high concurrency?

Use an asynchronous file response that reads with `aiofiles`, and modify Django’s handler to await the response’s asynchronous iterator. The speaker made these changes so file reads and sends do not block the server process.

Discussed at 8:33

Why do ordinary Gunicorn workers handle concurrent file downloads poorly?

A worker doing a blocking file read is busy until that download finishes, so other clients must wait for an available worker and may time out. Matching the number of workers to the number of simultaneous clients is possible, but it is memory-inefficient.

Discussed at 12:21

Are threads or async I/O better than processes for serving many files?

Threads use less memory than processes, while async coroutines are much lighter still—about two kilobytes each in the speaker’s estimate. A practical design is to use a small number of processes and limit the number of active coroutines per event loop so scheduling overhead does not take over.

Discussed at 14:42

How should Django serve private files securely?

Do not rely merely on obscure or hashed URLs, since links can leak. One option is to authenticate in Django and return an internal redirect such as Nginx’s `X-Accel-Redirect`, though this makes Nginx part of the security boundary and requires testing its configuration; signed URLs or cookies are another CDN-oriented workaround.

Discussed at 20:08

Does it make sense to use a CDN for large podcast or media files?

Often not: CDNs provide the most noticeable benefit for small assets where lower latency speeds up page loading, while large files incur substantial per-gigabyte traffic charges for little user-perceived improvement. For sufficiently large files, serving them from the application server may be cheaper if it has enough capacity.

Discussed at 25:30

How can I dedicate some Django workers to file downloads and keep the others for normal requests?

Split traffic at the reverse proxy or load balancer: route file requests to a separate application-server port using eventlet/gevent workers, and send normal short-running requests to a conventional synchronous Gunicorn server.

Discussed at 31:40

How much file-serving throughput can this setup handle?

The speaker’s anecdotal estimate was about 60–70 MB/s per Intel i5 core, suggesting that an eight-core machine might reach roughly four gigabits per second, though he had not tested a four-gigabit link. An M1 MacBook Air reached about 110 MB/s on one core in his comparison.

Discussed at 32:41

Open full transcript Markdown

Transcript

5,383 words · auto-generated · en Show transcript

Automatically transcribed, so expect mistakes in names and technical terms.

Jochen Wersdörfer

Okay, hello everyone, welcome to my talk serving files with Django. Let's get up the slides. Okay Maybe at first a little bit about myself. My name is Jochen Wester. I'm a freelance software developer from DĂĽsseldorf. I'm a long-term Python programmer. I learned a I learned about Django in 2013 and have used it in a lot of projects since then and But I'm also doing a lot of data science and machine learning stuff. I'm also co-host of a German

speaking podcast about Python called Python Podcast for which we didn't choose commercial podcast hosting provider and we didn't use an off-the-shelf podcast hosting software in PHP or something like that. Instead I wrote podcast hosting application using Django. Mainly because I'm not very clever. And that brings us to the topic of this talk because the main purpose of a podcast hosting application is to serve audio files to clients. And

yeah, this is what you can expect from the talk. It's not about managing assets, the parts of your application that are not source code. But instead just serving files from your application server while everybody is saying that this is not the recommended way to do it yeah. So the goal of all of this would be if I would be able to saturate the gigabit Ethernet connection I have on the application server at my hosting provider. If I would be able to saturate this connection with audio file downloads Then I would be happier and would say, okay, this is

this is solved for me. And Yeah, let's just jump into it and do some practical experiments to see if it's possible, whether it's possible or not or not. Yeah, for this benchmark I'll use gigaby connection between the MacBook running this presentation and Mac Mini. I have 125 files, each 10 megabyte in size, so they should saturate a gigabit connection for about 10 seconds. If it's a lot l a lot more than ten seconds, then it's probably then

we didn't saturate this gigabit. If it's a lot less, then physics is broken or time. The code for this benchmark is available via the link on the slide. Okay, I just fire up a terminal. Let's see. Oo I just start just start an application server. Pretty standard WSGI GUNicorn server with three worker processes to serve those 125 files. Nothing fancy, yeah. And

then I'll use this Jupyter Notebook. I forgot to clear the output to run the benchmark. Jupyter notebooks are great. I use them for my data science projects all the time. But I also really like to use them for Django projects because you can run Django Shell inside Jupyter Notebooks and then you can have your All your models at your fingertips you can try out stuff, just prototype some functions and then if you are ready copy them into your real source code. It's pretty amazing okay, let's let's do the benchmark. Mmm

okay. An arrow. Just scroll on. Nothing to see here. Okay, the next cell starts in the benchmark, so I'll switch over to the terminal again. And we can see okay, oh, there's a lot of stuff happening in the server log file, and then we see okay the gigabit connection is saturated. Looks good. Oh, and it's done. Didn't take much longer than ten seconds. Maybe exactly ten seconds. Really cool. That that wasn't difficult at all. Why are people saying that you shouldn't do that?

Looks like it has worked really great. Piece of cake. Yeah, I recorded the start and finish timestamps of all those file downloads. And yeah, let's plot them against time and bandwidth and Yeah, this leads to a really interesting image. This is looking a little bit weird Each line stands for one file download, but we see they are not really being downloaded concurrently. We know we have started all the downloads at the same time, but they didn't start at the same time. Pretty much started one after each other.

And only three at a time, and they used a lot of bandwidth. So this wouldn't work in a environment where Your clients have pretty low bandwidth connections, yeah. When you live in Germany, you know what I'm talking about? We pretty much only have low bandwidth connections here. And okay. Yeah, so this is not good. I Explain in more detail what's going on here later on, but yeah. So maybe we just need to run

a different is different application server. Okay Let's start UV-Corn, which is based on libuv. This is really fast event loop implementation, it's also about powering Node. js, it's battle tests that it's really fast. It's a nice abstraction above all those low level operating system. This calls you need to do You need to call to have fast networking, like e-pol on Linux. And yeah. Okay, and I also had to start two workers because otherwise this wouldn't be possible to saturate a gigabit. Okay, let's start the benchmark again.

Benchmar client again. Okay, we see yeah gigabit connection also gets saturated again, but nothing happens in the cyberlog. Maybe because the quests are still being delivered. Huh? Yes? No? Let's have a look at the timestamps from start to finish. Yeah, and we see all the Now all the downloads start at the same time, use one megabyte of bandwidth each, and then end all at the same time. And then this is the image we want to see. It's looking great So this is pretty much if I'm able to do this on my server, yeah, I'm I'm I'm I'm satisfied. This is this is this is great.

So yeah what did I have to do to make this work? Not really that much. I had to modify the standard Django file response a little bit because Usually it would just use a blocking read from the file and you can't do that because if you just read from a file then you are Server process will block and you can't do anything else. And here I have this dunder annext. method which uses AIO files library which maintains the thread pool for doing

AO IO operations on files asynchronously to enable this asynchronous read from the file. And it's the same mechanism, same library as used as in this file response class of starlet the framework which powers fast api. I did some initial benchmarks with fast API and what I was pretty impressed with the speed of fast API and then I So okay it's solid. Ooh there's there's this file response. And then I tried to steal just the file response class because I thought, oh it's also an HGI server, maybe I can just use it in Django.

But it's not really possible because The HGI handler is a little bit different. The HGI handler in Django iterates over streaming responses. For example, this line for part and response calls DunderNext, the DunderNext method for each part, but does it does it synchronously. So you can't await an asynchronous read in a in a synchronous function call. So yeah, it's not possible to serve a file asynchronously without modifying the SGI handlers. So I did that. I edit the code marked with this green

greenish background And I check for an attribute named Thunder A Itter and if it's there, then I assume okay this It's probably an async file response, and then I use async4 to call dunder a the anex methods asynchronously. And then I can use a way to read from the file, and then I can also asynchronously send back the data to the client. And those two modifications were all that was needed to do to make this work and have high concurrency file summing.

Yeah. So yeah. Those two images again. Okay. Yeah. But maybe there are other options when you have concurrency is a is a key thing here. And but maybe I think oh is not the only option you have to reach this goal, so I made a slide to give an overview of a different approaches in decreasing resource usage. You can add more machines, yeah. This would also increase your concurrency. You can put more cores in your machines, you can start more processes

yeah more threads or use async io so and those lightweight options might be the most suitable. Depends, but probably yes. So, okay, let's have a closer look at why it's a little bit difficult to achieve with processes. That would also explain the image we saw in the first benchmark. Let's say we have only two workers and four clients requesting four files at the same time. Then only client one and two will receive an response immediately. Client three and four have to wait, because worker one and two

are busy and can't do anything else. And not until worker one is finished has finished serving client one and becomes available again, and then client three will receive also a response and A little bit later, client 4 also will receive a response, but until then they have to wait. And maybe they just time out and user the user will see an error message. Just bad. So you probably need n workers to serve n clients concurrently. We can test this assumption. by just starting one hundred thirty

Processes instead of three And see if the image changes. We need to wait until all workers have started. Takes pretty long because G went the Journey convocers are big. Okay. Now they should be there. Then C, yeah. Gigabit connection also gets saturated. Okay, this looks nice. And now we see the same image for the process based concurrency as for the async based. So it's possible to serve a lot of requests concurrently using processes.

It's just not that efficient. Yeah, next option for example an additional G Unicon worker process needs about 30 megabytes of main memory. So if you want to start 1000 processes, you need 30 gigabytes of main memory and yeah, you get other problems too. So it's not really efficient. You can also use threads, threats are more lightweight, yeah, an additional thread would just allocate about 8 megabytes of main memory. And this memory is just virtual memory. It's not resident. Depends on what your thread exactly does, but It's probably a lot less memory usage than starting a new process.

And on a decent recent Linux system you should be able to start Yeah, about ten thousand threads without problems, and this should leave a lot of headroom for concurrent requests. We can Verify that by starting a G Vend Unicorn worker with 130 threads. So this started pretty quick compared to processes. And then we'll just measure it. Okay, yeah. Gigabit connection already saturated again. Nothing in the server log. Ten seconds. Okay. Let's have a look at the graph. Yeah.

Looks fine. Okay, yeah, threads are also working. Great. And we yeah, of course, have also async. io. Adding an active coroutine to event loop costs only about two kilobytes of main memory, so this is really cheap. But you have but adding coroutines is not really free because at some point The scheduling overhead for your coroutines will dominate the all of the things your application server process does.

So I don't know the exact number, but if you At thousands, tens of thousands, I don't know, coroutines. At some point your application server process will be busy just scheduling those coroutines and calling. signal handlers, choosing which coroutine to run next, stuff like that. And not being able to serve any more files or doing interesting business logic stuff. So but what you can do is start two processes for each call you have and then limit the number of active coroutines to let's say 100 or something like that And then distribute the low

the requests over those cores and processes and event loops and then you'll probably have a really high throughput networking system. Yeah, so okay, it seems like it's possible to serve files using your application server, but Maybe the established best practices are good enough. Why do it? Okay. For small files like assets. There's and files that are now on application start, there's this really great approach using a combination of white noise and a CDN.

White noise to handle the caching headers and initially solve the files file using send file, and then CDN to reduce the latency by moving the files closer to the client. There's a great talk about that assets in Django without losing your hair from Jacob Kaplan Moss from DjangoCon 2019, if I remember correctly. Or you can use just an dedicated web server like Nginx. Would also work. For user-uploaded files, this approach with white noise doesn't work anymore because it needs access to the files at application start time and yeah.

User uploaded files are not really known at application start and yeah for them you need some kind of an object store and maybe a cdn to serve them to the clients or Maybe also a dedicated web server. You shouldn't write those uploaded files into the file system where your application server lives because adding user controlled content to the server where to the filesystem of the server where your code runs, it's a pretty dangerous thing to do. So you need some kind of an object store and then. It'll be fine. It's yeah for the Python Podcast host side we also use

Amazon S3 and Cloud front as a CDN. Works great. So no need to serve files using your application server. For now. But what about serving private files? Well, yeah. The thing I see people doing in the wild usually is using proper authentication authorization for your for Django views and then serving file URLs to files to private files which are not really ri protected. If you know the URL, then you can access the file.

And yeah. If you ask them they say they have a cryptic name and we put a hash in the name and then nobody will be able to find them. Oh Yeah, but they could get leaked via some log file or it's it's it's not really it's a little bit ugly yeah for my taste. Better option would be to use dedicated server like nginx in front of your application servers so The file requests gets sent to your application server, then your application server checks authentication authorization. sends back an empty file response

with a special header telling nginx okay this request was valid and then engine x will replace your empty file response with the actual file response containing the file. This works, but Yeah, you now have two systems controlling access to your files and one is maybe tested, one not. Yeah, and if you use a content delivery network, you have the same problem. It can't really access your database and check whether permissions are given to view this file, yeah so you have to work around this using signed cookies or signatures in URLs. You can add a little bit more stuff in into them

like this URL is only valid for 30 minutes or it's only valid for clients accessing the file from this IP address. But it's a little bit like hiding your files because it's not really checking whether you are author authorized or not. Yeah, it's and the main problem I think is that you have to put a lot of trust in your into your systems working well together, which you usually shouldn't do because if someone messes up your Engine X config, then your Django application server test application tests won't tell you about it. So you

think everything is fine. Yeah, no one can access private files, but it's not true because your nginx config is broken, but you won't see it. Yeah, and same is true for the CDN solution because there are times when you don't when you cannot test. Your application using the real CDN. Yeah, when you're on the plane or don't have network connection. It's just impractical. Additional things you can do when you serve your files by your application server is putting advertisement into your podcast episodes or track users stop

listening to your podcast if you make a really bad joke yeah, I don't like those use cases because they are evil, but as a thought experiment, it's not that bad because for example the advertisement use case it's it would be quite complicated to do this with the CDN because If you have five spots where you are able to insert advertisement in your podcast episode, then you have to generate five different files. Six, one without advertisement and one which each spot filled and then upload all of this files to your CDN and then

Modify your feed to get your modified audio files delivered and then count put information in the log files of your CDN on how many times you have delivered a special file and then get this information back into your application server so you can stop messing with your feet f feet because you have delivered enough spots this would be this is a mess but if you just would add spots dynamically while serving the file. You can just stop after ten thousand spot playouts and then say okay it's fine. And you won't have modified a single audio file.

Just dynamically while serving. Yeah, maybe there are better use cases because I don't like advertisement, but yeah. There's also interesting point. For biggish files, C DNs are not really Cost efficient, maybe because Yeah, they are great if your files are small. The s the smaller your files, the better CDNs are. Because your site's performance will profit the most if reduced latency is measurable for the user.

So if C your CSS files and JavaScript files arrive quicker, then it will speed up your site and this will be really good. But if you have to wait a few seconds, because it's a big podcast episode, then it won't matter if whether it's fifty milliseconds. Faster or not. So it won't change the u the user experience. But it's much more expensive because you pay by gigabyte traffic. For example, the Python Podcast, small podcast but it generates a few hundred gigabytes of traffic each month, so I have to pay twenty to thirty dollars just

for the CDN traffic. But yeah. And I could have rented a decent application server for that price. And it wouldn't be traffic wouldn't cost me anything. For the application server. So maybe it's great to serve small files using a CDN, but if your files are bigger maybe solve them using your application server. So Okay, oh already So we are at the conclusion. Mm Yeah

All methods we tried to improve our concurrency in serving files did work. This is great. But you still have to look at your use case to choose the right method. And there are some things, for example, to consider. If you are using some asynchronous mess message queue you want to talk to while serving a file and it has an async interface and you have want to await it then you will pretty much have to use an ASGI server and an async view because otherwise you can't call await. It's not possible.

But okay, one more thing. If you are just want to increase the concurrency of your file responses. You can just maybe the easiest thing to do would be to use A G Event worker in Junicorn. Let's start the benchmark again. You'll see it also saturates the gigabyte gigabit connection nice and it's also Yeah, really good concurrency. Perfect.

Well. Yeah, and this was the WSGI interface and the standard Django file response. And files were served asynchronously and concurrently, disp in spite of using this traditional WSGI code and file response class And this is possible because Gven does a lot of really scary things like monkey patching, a lot of stuff in the SendEd library, like in the socket module, replacing all the read and write chords with own variants. And you have to l be a little bit brave, but if the only thing you want to do is serving files,

Maybe it's okay. And then you can isolate weird things that happen if you mucapatch everything, maybe by just splitting the traffic at your load balancer in file requests and the rest and the rest goes to the synchronous geunicorn application server and all the file requests go to the event g event worker. And then You don't have to do a lot, and you'll get pretty decent file serving capabilities for your Django application server. Okay, well I think that's it.

Thank you very much for your attention. I hope you still enjoy the conference and See you soon No, no, yes, yes.

Speaker 2

Yes, I have a practical question for if you want to use your approach of by serving through Django itself. Is there like a way to if you have like multiple workers to like dedicate some of the workers to the rest of your app like the normally I mean the like navigating pages etc and only then on specific workers only then for the file handling do you have some recommendations about that

Jochen Wersdörfer

Yeah, also the way I would do it is to split the traffic at the you also need probably reverse proxy before your application servers doing SSL offloading and load balancing. And there you could split the traffic between file responses and all the other requests and maybe you can just for the file responses run an application server on some different port and then do only file responses with an g event worker something like that and use a normal sync worker for all the normal short running requests. Yes.

Speaker 2

Okay, thank you. Hi

Speaker 3

Jochen.

Jochen Wersdörfer

Hello.

Speaker 3

I have a question. How far do you think you can go with this? How many gigabits can you serve? with this setup. I know that you've tested this on one with a bit

Jochen Wersdörfer

connection.

Speaker 3

But how far do you think you can push this?

Jochen Wersdörfer

Yeah for my for my okay I have some only anecdotal evidence I have Only a little bit of anecdot for this, but usually one core would be able to one I five Intel I five would be able to serve about 60 60 megabytes per second. So with eight cores I would think it's would be Probably possible to saturate four gigabit, but I don't know because I don't have a four gigabit link. It's also what really surprised me was thus that my M1 MacBook Air is per on a single core. It's much faster than my I also served tried serving from my

maxed out MacBook Pro I9 I9 and it yeah it's about I think seventy megabyte per second and the M1 is on one core by at one hundred ten megabyte per second, so it's a lot faster. And I wouldn't have expected that.

Speaker 3

So you you're telling us we should buy more hardware.

Jochen Wersdörfer

I don't know. Depends from where you want to serve your files because if you want to do it from home, maybe but hosted M1 variants are relatively expensive. So Maybe it's cheaper to just buy more servers that are not M1.

Speaker 3

All right. Thank you very much. There are some questions in the chat. That people

Jochen Wersdörfer

Big send file. Yes. Yeah, the question this was also addressed in the talk and I also couldn't really follow it. But and then I learned I had to drop the quality a little bit and then it worked. Yeah, using Xen file is a lot better than just obfuscating the file names. But yeah it's also not that clean because it's it's it's not that easy to test against. You can't always have the full your full architecture running when you just want to ru to run your application tests and but if you want to test your complete system and

Yeah, using Xand file means that your Nginx is now part of your application and you have you have to test its configuration to be sure that no one can access your protected files then you would also have to run an Nginx in for a test time or for in development time, which is kind of unpractical. And also it's not really possible to may probably won't serve files from the file system, but from some S3 compatible object store. And yeah, that means probably running some kind of a Minio Min IO server. And you also won't won't really

wouldn't really do that in a in the for development. environment. So I think it's it's yeah, it's it's it's maybe the best option. The closest one to serving files directly from the application server in respect to security but Yeah, it's also a little bit impractical, but it's definitely possible. And what would be really interesting for me is to see whether engine X is faster serving files from menu, for example. Which would be really interesting, but I doubt it because it's only if you if you just copy some blocks of data from one socket to another, then it shouldn't matter if it

if you do it in Python or if it if you do it in C because yeah the operating system is doing all the hard work and you are just telling the operating system what to do. You are just orchestrating the operating system. So I it would surprise me if Nginx is a lot faster. It would be a lot faster if it can use sendfile, but I think it's not possible to use sendfile in this scenario. The link in the code. It's to the code is in on the slide title practical experiment. I can Make it visible here? It's a code for this benchmark link.

Should work.

Speaker 3

Is that linked on your on your talk page?

Jochen Wersdörfer

Yes.

Speaker 3

Excellent. Thanks.

Jochen Wersdörfer

On the on this practical experiment thing. Oh yeah. No, I have oh I'm I'm double. Let's see. Okay. Yeah. Header, test the header response in development. Yes, of course. You can test if the header was set correctly But you have to trust your Nginx configuration. Yeah. And what's also not that not that cool is that your engine X now has to have access to all your users' private files, which is if there's some security problem with Nginx, then yeah, you're exposed.

It's it's just a little bit more attack surface. Yeah. The question is some people just copy the private files to a public space web space where everyone can access us and use maybe hashes of the contents of the files as file names. But yes, this is this is what variants of this is what most people do. And I think it's it's not really good but because those URLs which are generated. Yeah it maybe if you do it temporarily, But those URLs can leak somewhere. Maybe in a log file, maybe on the client side, w when

someone clicks on a bad email. or if someone shared this those links via some instant messenger and then all those people getting access to those URLs are able to get access to the files which is problematic in my opinion. So yeah, maybe it works, maybe it's it's enough to just obfusc obfuscate maybe the files, but and this is what most people do, but Yeah, I'm I wouldn't feel very comfortable if it were my users and my system.

Speaker 3

Yeah I think another item on that list is caching because if you have these files accessible somewhere they will be cached on in many places. on the internet and they'll just leak in like in the middle. And that's probably not good.

Jochen Wersdörfer

Yeah. But if you if you use H HTTPS

Speaker 3

Yeah, okay, yeah. In that case they will be they will be quite safe. That's true.

Jochen Wersdörfer

Oh. I hear some weird audio. Okay. It's oh sorry, it was just loud spawn being loud.

Speaker 3

Well I'm going to log on. Thank you, Johan, for your talk.

Jochen Wersdörfer

Yeah.

Speaker 3

See you soon.

Jochen Wersdörfer

Let's see when we yeah, can meet each other again. Bye.

Speaker 2

Thank you. Bye.

Conference

DjangoCon Europe

June 2 - 6, 2021

Online

Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.

More videos by Jochen Wersdörfer

More videos from DjangoCon Europe