Web based system to purge multiple Varnish cache servers

Posted by: Admin  :  Category: Web Hosting

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Hello!

We have been working with varnish for quite a while. And there is quite a lot of documentation out there already for the different methods for purging cache remotely via Curl, the varnish admin tool sets and other related methods.

We deal with varnish in the Amazon Cloud as well as on dedicated servers. In many cases varnish sits in a pool of servers in the web stack before the web services such as Nginx and Apache. Sometimes purging specific cache urls can be cumbersome when you’re dealing with multiple cache servers.

Depending on the CMS you are using, there is some modules / plugins that are available that offer the ability to purge Varnish caches straight from the CMS, such as the Drupal Purge module.

We have decided to put out a secure, web accessible method for purging Varnish cached objects across multiple varnish servers. As always, take the word “secure” with a grain of salt. The recommended way to publish a web accessible method on apache or nginx that gives the end-user the ability to request cache pages be purged would be to take these fundamentals into consideration :

– Make the web accessible page available only to specific source IPs or subnets
– Make the web accessible page password protected with strong passwords and non-standard usernames
– Make the web accessible page fully available via SSL encryption

On the varnish configuration side of things, with security still in mind, you would have to set up the following items in your config :

ACL

Set up an access control list in varnish that only allows specific source IPs to send the PURGE request. Here is an example of one :

# ACL For purging cache
acl purgers {
        "127.0.0.1";
        "192.168.0.1"/24;
}

vcl_recv / vcl_hit / vcl_miss / vcl_pass

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

This is self explanatory (I hope). Obviously you would be integrating the following logic into your existing varnish configuration.

sub vcl_recv {
        if (req.request == "PURGE") {
                if (!client.ip ~ purgers) {
                        error 405 "Method not allowed";
                }
                return (lookup);
        }
}

sub vcl_hit {
        if (req.request == "PURGE") {
                purge;
                error 200 "Purged";
        }
}
sub vcl_miss {
        if (req.request == "PURGE") {
                purge;
                error 404 "Not in cache";
        }
}
sub vcl_pass {
        if (req.request == "PURGE") {
                error 502 "PURGE on a passed object";
        }
}

The code itself is available on our GitHub Project page. Feel free to contribute and add any additional functionality.

It should be important to note that what differentiates our solution among the existing ones out there is that our script will manipulate the host headers of the Curl request in order to submit the same hostname / url request across the array of varnish servers. That way the identical request can be received by multiple varnish servers with no local host file editing or anything like that.

There is lots of room for input sanity checks, better input logic and other options to perhaps integrate with varnish more intuitively. Remember this is a starting point, but hopefully it is useful for you!

The post Web based system to purge multiple Varnish cache servers appeared first on Managed WordPress Hosting | Managed VPS Hosting | Stack Star.

Managed WordPress Hosting | Managed VPS Hosting | Stack Star

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Shine Servers LLP Launches New Mobile Website!

Posted by: Admin  :  Category: Web Hosting News

The post Shine Servers LLP Launches New Mobile Website! appeared first on Web Hosting Talk.

Web Hosting Talk

Reliable dedicated servers are one stop solution for your IT business

Posted by: Admin  :  Category: Web Hosting

This article discuss about windows and Linux servers. Their advantage and usage in IT business and how it could save you money and effort with dedicated support from the company.
Find Articles, Free Articles Directory | Web Hosting Articles

A Few Factors Regarding World Of Warcraft Servers

Posted by: Admin  :  Category: Web Hosting

Online games offer high value entertainment for people, who spend a substantial portion of their time in front of the computer.
Find Articles, Free Articles Directory | Web Hosting Articles

How To Locate The Best Minecraft Private Servers

Posted by: Admin  :  Category: Web Hosting

Online games are a prime source of entertainment for people who spend a substantial portion of the day in front of the computer. Some of these games offer a great opportunity to relax after a grilling work schedule.
Find Articles, Free Articles Directory | Web Hosting Articles

Get a More Awesome Gaming Experience by Playing on the Top Minecraft Private Servers on the Web

Posted by: Admin  :  Category: Web Hosting

Video games have evolved to be a major source of entertainment across the world. No other mode of entertainment involves the person as much as video games. Often we find people engrossed in the game as the hours pass by silently.
Find Articles, Free Articles Directory | Web Hosting Articles

How To Gain From Game Private Servers

Posted by: Admin  :  Category: Web Hosting

Online games are a preferred mode of entertainment for people, who have to spend a substantial portion of their time indoors. However, a key benefit of these games is that, they offer the player, a lot more than pure entertainment value.
Find Articles, Free Articles Directory | Web Hosting Articles

Why Minecraft Private Servers Is The Best Online Game

Posted by: Admin  :  Category: Web Hosting

The world of computers and internet technology has done its bit to implement drastic changes in human lives.
Find Articles, Free Articles Directory | Web Hosting Articles

Receive convenient web solution and servers from experts

Posted by: Admin  :  Category: Web Hosting

Below is the article written to give you details about a company who are offering web development and technology solutions for your business using latest server.
Find Articles, Free Articles Directory | Web Hosting Articles

Hivelocity Introduces 7 Minute Bare-Metal Servers

Posted by: Admin  :  Category: Web Hosting News

The post Hivelocity Introduces 7 Minute Bare-Metal Servers appeared first on Web Hosting Talk.

Web Hosting Talk