Tuesday, September 8, 2015

Varnish on Windows (using Cygwin)

This post details how to run Varnish on Windows (using Cygwin) .

Install Varnish and Cygwin on Windows

To install Varnish and Cygwin on Windows, refer to download and installation instructions at:
https://www.varnish-cache.org/trac/wiki/VarnishOnCygwinWindows#InstallFullCygwinenvironmentwithvarnishpackage

Configure default.vcl file

  • Take a copy of default.vcl file located at {cygwin_install}/etc/varnish
  • Now open default.vcl and configure backend default
I am giving port 3000 because it is the default port for node.js

backend default {
     .host = "127.0.0.1";
     .port = "3000";
 }


Start up Varnish

On cygwin window, type following command to startup varnish
$ /usr/sbin/varnishd -d -f ./etc/varnish/default.vcl -a 127.0.0.1:6081

This will start up Varnish in debug mode, so that you can monitor it.

Once started, list the processes
$ ps -ef | grep varnish

you should see varnish process started.

Issues with Varnish on Cygwin and solution:

Panic message: Assert error in sock_test(), /usr/src/varnish-3.0.5-1/src/varnish-3.0.5/bin/varnishd/cache_acceptor.c line 166:

  Condition(l == sizeof tcp_nodelay) not true.

Solution:
You will need to download the varnish src (varnish-3.0.5-1-src.tar.xz) and remove the assert statement at varnish-3.0.5/bin/varnishd/cache_acceptor.c line 166

Then recompile and install:
  • cygport varnish-{version}.cygport prep
  • cygport varnish-{version}.cygport compile
  • cygport varnish-{version}.cygport install

More details for compile at - http://sourceforge.net/projects/cygvarnish/files/cygport-packages/64%20bits%20%28x86_64%29/


2 comments:

  1. /usr/sbin/varnishd -d -f ./etc/varnish/default.vcl -a 127.0.0.1:6081 gives the following error,
    bash:/usr/sbin/varnishd no such file or directory

    what is the problem and how to rectify this

    ReplyDelete
  2. User@dh-27 /cygdrive/c
    $ /usr/sbin/varnishd -d -f /etc/varnish/default.vcl -a 127.0.0.1:6081
    Failed to create ./vcl.NGq8CngC.c: Permission denied
    VCL compilation failed


    i got this above error ,can you suggest a try

    ReplyDelete