Setting up Debian with Varnish as internet proxy

By | 2010-07-30

Varnish is a great http accelerator, “10 times faster than squid”. This partially due to its use of modern computer architecture. Although its main purpose is as a web server accelerator it can also be used as a traditional internet accelerator/cache. The web page FAQ says it requires a lot of work though.

But there is a simpler solution by having it cooperate with Squid. Not the most elegant solution, but for my cable modem it will be more than enough.

  1. Install Debian on a box.
  2. Install Squid and Varnish.
    apt-get install squid varnish
  3. Edit /etc/squid/squid.conf (this is actually optional, but recommended):
    Add the lines:
    cache_dir ufs /var/spool/squid 10 2 4
    forwarded_for off
  4. client_db off

  5. Edit /etc/default/varnish and set
  6. DAEMON_OPTS=”-a :6081 \
    to
    DAEMON_OPTS=”-a :8080 \
    And

    -b localhost:8080 \
    to
    -b localhost:3128 \

    Add the line: -f /etc/varnish/default.vcl \
    after -b line.
    Set how much disk space you want to use for cache in the line:
    -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G”
    Note: For 32-bit systems keep it low (~1GB).

  7. Restart Squid and Varnish:
    /etc/init.d/squid restart
    /etc/init.d/varnish restart
  8. On your client computer set your HTTP PROXY server for HTTP (not HTTPS) to debianserverip port 8080.

image

2 thoughts on “Setting up Debian with Varnish as internet proxy

  1. Roy Sigurd Karlsbakk

    Testing with Ubuntu Lucid 10.04 amd64 shows me this didn’t work too well. I tested Squid directly, and that works, but for some reason Varnish doesn’t want to play ball:

    Error 503 Service Unavailable

    Service Unavailable
    Guru Meditation:

    XID: 1309427290
    Varnish cache server

    Reply
    1. tedd Post author

      Check varnishlog to see what is causing the stop. Default Varnish-config should work just fine for pass-through with caching. Hmmm… I see I’ve got “-f /etc/varnish/default.vcl \” as well in my working copy. Updating post. :)

      Reply

Leave a Reply