Hot answers tagged

40 votes

Ordering: 1. nginx 2. varnish 3. haproxy 4. webserver?

Foreword Update in 2016. Things are evolving, all servers are getting better, they all support SSL and the web is more amazing than ever. Unless stated, the following is targeted toward ...
  • 2,829
27 votes

Prevent port change on redirect in nginx

I my case nginx listens to port 80 inside a docker container but it's mapped to port 8080 (or any random port) outside the container. There is no reverse proxy in-between that can add proper headers ...
  • 411
17 votes
Accepted

varnish daemon not listening on configured port

You need to change the varnish start parameters in the systemd service definition as well. You could edit the line starting with ExecStart in the service defintion file: sudo vi /lib/systemd/system/...
15 votes

Change varnish 4 503 error

I would like to propose an alternative... please find below a sample default.vcl file vcl 4.0; import std; backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_backend_response ...
14 votes

Ordering: 1. nginx 2. varnish 3. haproxy 4. webserver?

All other answers are pre-2010, hence adding an updated comparison. Nginx A full web server, other features can also be used. Eg: HTTP Compression SSL Support Very light weight as Nginx was designed ...
  • 279
14 votes
Accepted

What are the commands to get top MISSES and HITS from Varnish 4?

In Varnish 4 varnishtop -i BereqURL will provide you with an updating list of URL requests going to the back-end (Misses). varnishtop -i ReqURL will provide you with an updating list of ALL ...
14 votes
Accepted

Does it makes sense from a security perspective to remove the Server HTTP header?

RFC 7231 says about the Server header: An origin server MAY generate a Server field in its responses. MAY is interpreted as in RFC 2119: MAY This word, or the adjective "OPTIONAL", mean ...
12 votes

Get varnishlog to log only 503 errors into file

For those who land here in frustration looking for solution to the same problem in Varnish 4, see below: varnishlog -a -w /var/log/varnish/varnish50x.log -q "RespStatus >= 500 or BerespStatus >=...
  • 351
7 votes

Is it possible to run varnish with both memory and disk storage?

You need to name storage respectively as follows and in vcl you specify which backend storage you want to use with beresp.storage = storage_name. . Varnish 3.* process options DAEMON_OPTS="-a :80 \ ...
  • 298
7 votes
Accepted

How to disable Varnish

if you use CentOS or Red Hat, use this: service varnish stop if you want to uninstall varnish, try this: yum erase varnish or refer to https://stackoverflow.com/questions/27739853/varnish-cache-...
  • 186
7 votes
Accepted

How to Enforce SSL in Varnish 4

Try the following for Varnish 4 while updating the TLD with your respective values: sub vcl_recv { if ( (req.http.host ~ "^(?i)www.domain.com") && req.http.X-Forwarded-Proto !~ "(?i)...
  • 377
7 votes
Accepted

Cannot install Varnish on CentOS 7

I don't know whose instructions you were following, but either the instructions were wrong, or they were the wrong instructions. On a clean CentOS 7 system you can install Varnish 4 simply by: yum ...
7 votes
Accepted

Extract Configuration From a Running Varnish Instance

In your case, I think your best shot would be the command varnishadm vcl.show boot (replace boot by active configuration's name, see varnishadm vcl.list output).
  • 241
7 votes

varnish daemon not listening on configured port

Note that the drop-in should have an empty ExecStart= Otherwise you will get an error starting the service (duplicate ExecStart) sudo mkdir /etc/systemd/system/varnish.service.d sudo nano /etc/...
  • 171
6 votes
Accepted

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

Ended up with this table: **Nginx**: ngx_http_sub_module --> http://p.defau.lt/?A6UukYFKZrYLalJ5KOuTKg **Nginx**: Nginx + lua. LUA body_filter --> http://p.defau.lt/?0ZxLWENoEkFIRD17QlEtbQ **...
6 votes

Best practice for proxying package repositories

We use Squid for this; the nice thing about squid is that you can set individual expiry of objects based on a pattern match, fairly easily, which allows the metadata from the yum repo to be purged ...
  • 484
6 votes
Accepted

Does Varnish 5.0 support HTTP/2 for backend connections?

@Michael Hampton's answer is missing some points so here it goes: Varnish is the one software that does HTTP/2 in Hitch+Varnish combo, but most of the browsers requires TLS connection in order for ...
5 votes

Does Varnish require much RAM?

Varnish actually supports multiple storage backends. You can cache something to RAM, whereas something to disk: -s default=malloc,256m \ -s static=file,/var/lib/varnish/varnish_storage.bin,1G" This ...
5 votes

Varnish ACLs Behind Load Balancer Based on Client's IP

This can be done using std.ip, assuming ClientIP header is already set in vcl_recv(). For example: vcl 4.0; import std; acl admin_net { "10.10.1.160/27"; } sub vcl_deliver { if (std.ip(req.http....
  • 124
5 votes
Accepted

Error setting up haproxy and varnish

That article is over 3 years old and there's been 2 stable releases of HAProxy since then, so I suspect that's why it's not working verbatim. If I had to guess your exact problem, I'd say it has to ...
  • 9,160
5 votes

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

Varnish does not support SSL Running a site/service on SSL is a necessity for anything half serious, so thats one reason to use haproxy which will do SSL termination for you.
  • 3,552
5 votes

Best practice for proxying package repositories

That's a definitive use case for a proxy. A normal proxy, not a reverse-proxy (aka. load balancers). The most well-known and free and open-source is squid. Luckily it's one of the few good open-...
  • 2,829
4 votes

Varnish VCL - Regular Expression Evaluation

There is a trick! Change the condition if(!req.http.Cookie ~ req.http.regex) to: if(!req.http.Cookie ~ {"" + req.http.regex + ""}) This switches it to a CSTR.
4 votes
Accepted

Change varnish 4 503 error

There are two kinds of errors in Varnish 4. One is backend fetch errors.vcl_backend_error handles this kind of errors. Another is errors generated in VCL. vcl_synth handles this kind of errors. In ...
  • 298
4 votes
Accepted

Varnish with MediaWiki not caching

Take a look at your request headers. Cache-Control:no-cache and Cache-Control:max-age=0 Edit: These were not the cause of trouble and can be safely ignored. Varnish documentation stating: ...
  • 3,927
4 votes

Filtering varnishlog v4

You have to use the tags described here: http://book.varnish-software.com/4.0/chapters/Examining_Varnish_Server_s_Output.html#query-language By example: varnishlog -n varnish-instance-name -q '...
  • 191
4 votes
Accepted

How can I view n_lru_nuked in varnish 3.0.5?

No one else has offered anything up here. I thought I would let you know you're not alone trying to find the answer. I have the same question and I'm starting to think varnishstat perhaps doesn't ...
4 votes

Best practice for proxying package repositories

This won't solve all your tasks, but maybe this is still helpful. Despite the name, apt-cacher-ng doesn't only work with Debian and derivatives, and is a caching proxy. Specialized for package ...
  • 5,533
4 votes
Accepted

Google Ads and Varnish

The ads will not be cached, because Google ads are Javascript based. (the actual ads are pulled by Javascript code into your page dynamically, irrespective of Varnish cache).
4 votes

Redirect HTTP to HTTPS using Varnish 4.1

The below works: sub vcl_recv { if (client.ip != "127.0.0.1" && req.http.host ~ "example.com") { set req.http.x-redir = "https://example.com" + req.url; return(synth(850, "")...

Only top scored, non community-wiki answers of a minimum length are eligible