Configure Varnish

From Fabelier
Jump to: navigation, search

Here is a little example about configuring Varnish in the fabelier's dev server to host a project. If any question, ask Julien (julien at palard point fr)

  • First, edit the file /etc/varnish/default.vcl (If you use emacs, M-x c-mode and enjoy syntax highlighting as vcl ils inspired by c)
  • Add a backend for your project, here it's "YourStuff" :
 # YourName : YourComment...
 backend YourStuff
 {
   .host = "127.0.0.1";
   .port = "8090";
 }
  • In the `sub vcl_recv`, add a condition that match your url (checking for req.url) / host (checking for req.http.host) / whatever. If you *haven't* query yet (on your browser or other..) your future sub domain of "mystuff".dev.fabelier.org, you can attribute it by yourself like that :
 if (req.http.host == "yourstuff.dev.fabelier.org")
 {
     set req.backend = YourStuff;
 }
  • If necessary, fine tune the TTL for your responses, default is 10mn :
 if (req.backend == YourStuff)
 {
     set beresp.ttl = 300s;
 }
  • Reload varnish (never restart, in case there is a bug in your configuration file !) :
 $ /etc/init.d/varnish reload
 Reloading HTTP accelerator: varnishdCommand failed with error code 106
  • Damned, there is a bug in varnish's default.vcl, that's nice there is a command to check it:
 $ /usr/sbin/varnishd -Cf /etc/varnish/default.vcl
 Message from VCC-compiler:
 Syntax error at
 (input Line 29 Pos 19)
    if (req.http.host == yourstuff.dev.fabelier.org")
 ------------------#------------------

Fix it, reload, enjoy !

File too big to be handled by Varnish ? a quick fix is to add :

if (req.url ~ "\.zip$")
   {
       return (pipe);
   }
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox