Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 want to use varnish to server static files directly from django, just for benchmarking purposes.
Does varnish support serving static files directly from filesystem?

I'm actually looking for nginx's equivalent "alias" command:

location /media {
       alias    /var/www/djangosite/media;
share|improve this question
up vote 2 down vote accepted

no varnish is a reverse proxy. You sit it in front of say nginx and tell it to cache search file types or pages that have a response header and how to cache it.

share|improve this answer
thanks for the clarification, I'll probably go with lighttpd to serve static files and varnish in front of it to cache them – goldstein Sep 28 '11 at 23:35

Maybe I'm not understanding your question, but I think what you want to do is pass() certain static file types straight through Varnish to your backend (Nginx, Apache, etc).

We're doing something like that with a static image files that we do not ever want cached using this in VCL_recv():

if (req.url ~ "\.((?i)png|gif|jpg|swf|css|js|ico)$") {
   return (pass);

Is that what you're looking for?

share|improve this answer
No, I have varnish in :80 and apache in :8080. All I want is to alias "/media" to "/var/www/django/site/media" just like nginx. – goldstein Sep 28 '11 at 23:30
That's a standard setup with Varnish on 80 and Apache on localhost 8080. Unless there is some subtlety I am missing you could modify my code to match anything with /media (or a longer string if your request URL is predictably longer) in it to return (pass). Something like if (req.url ~ "/media") { return (pass) }. Or maybe I am missing the point altogether. – jdw Sep 29 '11 at 0:03
Oh. Yeah. I get what you're trying to do now. My answer is useless. My bad. – jdw Sep 29 '11 at 0:09

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.