Proof-Of-Concept filesystem capabilities module for Varnish 4
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Varnish FileSystem Module

Author: Dridi Boukelmoune
Date: 2013-04-25
Version: 0.1
Manual section:3


import fsdirector;


With this module, you can make Varnish serve static files from your file system without an additional server such as Apache HTTPD. The module actually starts a server thread that will answer Varnish's HTTP requests with static files.

This is a play with Linux system calls and Varnish internals Proof of Concept VMOD. Do I need to mention this is not suitable for production use ? You are warned ;)


In order to build and run the VMOD, you will need:

  • Varnish 4 (just in case ;-)
  • libmagic

Do not hesitate to report any missing dependency.


This VMOD was initially an attempt to create a filesystem director, in order to test backends manipulation (more precisely directors) introduced by Varnish 4.

Obviously, it failed, but instead of creating a director, I use a backend declared in the VCL and create a server thread with the backend's parameters. By the way, I try to reuse Varnish's code instead of writing my own for several reasons:

  • developer => lazy
  • it forces me to read and understand lots of code written by experienced C developers

There is a strong probability that the director attempt failed because I didn't use Varnish's internals properly. You can read the commit log to know the steps I go through while writing it, I'm still playing with it when I want to try stuff.


This is very easy to use:

import fsdirector;

backend static {
   .host = "";
   .port = "8080";

sub vcl_init {
   new fs = fsdirector.file_system(static, "/var/www");

See src/tests for more examples.


This document is licensed under the same license as the libvmod-fsdirector project. See LICENSE for details.

  • Copyright (c) 2013 Dridi Boukelmoune