Blog Tenya.me

some blog : )

Varnish 3.x custom error pages

| Comments

Most VCL examples and Varnish wiki offers two solutions for custom error pages. First one is a strict HTML code in a synthetic block and second one is a reading html file from disk with inline C. Both variants work, but makes our VCL code nasty (also second variant with inline C reads file from disk on every ‘wrong’ request).

I want to suggest third variant, that combines both previous variants without their bad side.

PKGBUILD: nginx-custom

| Comments

Proudly presents my own nginx PKGBUILD for AUR (ArchLinux User Repository) with additional and 3d party modules:

  • Standard HTTP Modules
  • Optional HTTP Modules: Debug, Gzip Precompression, Stub Status, IPv6, SSL, Real IP, Secure Link, Addition, XSLT, MP4, FLV, Substitution, Image Filter, Embedded Perl, Degradation, Random Index
  • 3d Party Modules: Upstream Fair, Echo, Upload Progress, Cache Purge, Headers More, SlowFS Cache

Link to AUR

Varnish with simple Virtual Hosts

| Comments

Usually we have more than one development environments for projects on our development servers or workstations. And part of them needs to be proxied with Varnish.

Varnish configurations may be same and may be different. One or three different configurations may be stored in default configuration file (default.vcl). But if count of configurations grows up, then file becomes unreadable and inconvenient.

I suggest to use a simple solution to split configurations to separate files and include them in main configuration file. It add some overhead for same configurations, but makes confuguration easier.

Varnish HTTP Authentication

| Comments

Sometimes we need restrict access to site that cached by Varnish with basic HTTP authentication.

Basic method is enable it on backend (Apache, nginx, lighttpd or other web-server). But after the first correct request, it will be cached on Varnish and all other clients requests would be without authentication.
Solution for this situation is pass all request with authentication to backend with next statement:

Pass authorization to backend
1
2
3
4
if (req.http.Authorization || req.http.Authenticate)
{
  return (pass);
}

As we remember, caching still required for this site. So, statement above is not suitable for our conditions.

Good workaround is to check HTTP authentication at the Varnish.
Well then do it in VCL.