Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using nginx and need to serve only Nbytes of a file (or seconds/minutes limit of serving). How is it possible to do it with nginx?

share|improve this question

I would recommend you serve the file through a script with php or something. I'm not sure this is possible with Nginx alone.

share|improve this answer
Agreed. This is not nginx's responsibility to do that. A script would also grant you better control over the aspects of this. – vmfarms Aug 20 '10 at 17:11
+1. This is the job of a specialized script / application. – Michael Gorsuch Aug 21 '10 at 2:27

I found myself a workaround to use limit_rate , and limit_rate_after, so limit_rate I set to 1, and limit_rate_after the time after which we would like to stop serving the file. The result is that the connection is limited to 1 byte/s after a certain period of time. The bad thing is that the connection is active and there is traffic (even 1 byte/s) and it is not going to time out. limit_rate 1 limit_rate_after 5m

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.