Questions tagged [varnish]

Varnish is a high-performance reverse proxy and load-balancer package for Linux/Unix systems.

Varnish is primarily a caching reverse proxy, but also exhibits load-balancing and backend checking mechanisms and is very widely used on high traffic websites.

Varnish was designed from the ground to be a high performance reverse caching proxy and to not compete with the operating system on managing resources like memory. Most recent versions of Varnish support storing cache on memory or disk, and serving old content in case of backend fail (saint mode), among other features.

Varnish is written by Poul-Henning Kamp (PHK), and his Architect Notes are available about varnish design. PHK is also a well known FreeBSD kernel developer and mantainer.

937 questions
7
votes
2 answers

How do I block an IP address or network block with Varnish VCL?

How does one block either IP address of network range inside of Varnish's VCL file?
alexus
  • 13,112
  • 32
  • 117
  • 174
6
votes
1 answer

How to Enforce SSL in Varnish 4

I am aiming to redirect clients to a SSL-version of a site using Varnish. In Varnish 3 this could be done by the following in the VCL: sub vcl_recv { if ( (req.http.host ~ "^(?i)somesite.org" || req.http.host ~ "^(?i)www.somesite.org") …
Taylor Taff
  • 463
  • 4
  • 9
6
votes
2 answers

Get varnishlog to log only 503 errors into file

I tried everything: service varnishlog start - logs everything varnishlog -D -c -m TxStatus:503 > /var/log/varnish/varnish.log - doesn't seem to be doing anything varnishlog -c -m TxStatus:503 > /var/log/varnish/varnish.log - only logs until I close…
Eduard Luca
  • 371
  • 2
  • 9
  • 19
6
votes
1 answer

Should I enable KeepAlive on Apache backend with Varnish as frontend?

I'm using Varnish as a frontend with Apache 2 as backend on my web server. What are the pros and cons of Apache's KeepAlive in this setting? Apache and Varnish run on the same server now, but I could put them on different servers in the future.
Christian Davén
  • 401
  • 1
  • 4
  • 13
6
votes
3 answers

Tools for introspecting Varnish

Has anyone developed, or does anyone know of, any third-party tools (or non-obvious uses of the stock tools) to help a poor systems administrator determine what's going on with requests that are passing through Varnish? While varnishstat,…
womble
  • 96,255
  • 29
  • 175
  • 230
6
votes
2 answers

Optimizing Server Architecture with Apache/Varnish/MySQL on Linux

I am a server administrator for a small start-up as a side venture (meaning I am by no means a well seasoned expert on the subject), and I recently helped move the site from a single windows machine to a cluster of machines on Rackspace…
WerkkreW
  • 5,969
  • 3
  • 24
  • 32
6
votes
2 answers

How to make Varnish ignore, not delete cookies

I want to use Varnish to cache certain pages even in the presence of cookies. There are 3 possibilities that I need to take care of: An anonymous user is viewing some page A logged in user is viewing some page with light customization. These…
Jason Christa
  • 622
  • 4
  • 11
  • 21
6
votes
4 answers

How do I get varnish to return in the http response header from which backend it took the response?

I have three servers in the backend, with a round robin director. I would like varnish to write a X-Server-By header with the name or ip of the server from which the response was fetched, how can this be done?
pzol
5
votes
5 answers

Nginx, Varnish, ESI - Will that work?

I've serveral backends (one is nginx+passenger) to combine via ESI. Since I don't want to go without gzip/deflate and SSL varnish can't do the job out of the box. So I thought about the following…
Roland
  • 369
  • 3
  • 9
5
votes
1 answer

Possibility of rewriting response bodies in different webservers (nginx, apache, iis, etc.)

I'm doing a personal research on the differences between commonly used web servers. I'm struggling to find clear answers when it comes to particular features and most importantly for me: ability to rewrite response body on the fly. Scenario: a web…
5
votes
1 answer

How to hash based on host + path in Varnish?

I want to use the hash director in Varnish to redirect all requests for a same URL without query parameters to the same server: For example, http://example.com/foo/bar?a=1 http://example.com/foo/bar?a=2&b=3 Should hash to the same server. I want to…
BenMorel
  • 4,507
  • 10
  • 57
  • 85
5
votes
3 answers

Is HAProxy still necessary when Varnish can act as a load balancer?

I would like to load-balance my application servers, as well as cache the responses from them. I've read an article dating back to 2012 on HAProxy's website, that was supposed to clear the confusion between HAProxy and…
BenMorel
  • 4,507
  • 10
  • 57
  • 85
5
votes
1 answer

Nginx in front of Varnish sometimes produces "upstream prematurely closed connection while reading response header from upstream" error

I have Nginx(1.9.9) on front of Varnish(4.1.0) on the same server. //nginx upstream varnish { server 127.0.0.1:8391; keepalive 16; } location ~ \.php$ { proxy_pass http://varnish; proxy_http_version 1.1; #for 1.0 varnish shows…
5
votes
2 answers

Extract Configuration From a Running Varnish Instance

Is there a way to extract a vcl configuration file from a running instance of varnish? That is, I'm debugging varnish on a system I haven't been involved with up until now. There's a lot of confusion from the system owners as to which varnish…
Alana Storm
  • 458
  • 5
  • 16
5
votes
1 answer

Puppet: How to skip restart during package upgrade until config is replaced?

I'm trying to get Puppet to upgrade our Varnish 3 servers to Varnish 4, a major update which requires an updated config file or it won't start. This is on Ubuntu 12.04. The Varnish module is essentially built with these classes and…
Martijn Heemels
  • 7,728
  • 7
  • 40
  • 64