Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # This is an example VCL file for Varnish.
- #
- # It does not do anything by default, delegating control to the
- # builtin VCL. The builtin VCL is called when there is no explicit
- # return statement.
- #
- # See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
- # and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.
- # Marker to tell the VCL compiler that this VCL has been adapted to the
- # new 4.0 format.
- vcl 4.0;
- # Default backend definition. Set this to point to your content server.
- backend default {
- .host = "127.0.0.1";
- .port = "81";
- }
- backend onedomain {
- .host = "127.0.0.1";
- .port = "81";
- }
- backend newdomain {
- .host = "127.0.0.1";
- .port = "81";
- }
- acl purge {
- "localhost";
- }
- sub vcl_recv {
- # Happens before we check if we have this in cache already.
- #
- # Typically you clean up the request here, removing cookies you don't need,
- # rewriting the request, etc.
- #Bypass large files
- if (req.http.x-pipe-mark && req.restarts > 0) {
- return(pipe);
- }
- # all domains in here will return a "pass" which means they won't be cached
- if (req.http.host ~ "(www\.)?(domain1.com|domain2.com)") {
- return (pass);
- }
- #else check if something we're going to cache
- else if(req.http.host ~ "(www\.)?(onedomain.nu)") {
- set req.http.host = "onedomain.com";
- set req.backend_hint = onedomain;
- }
- else if(req.http.host ~ "(www\.)?(newdomain.com)") {
- set req.http.host = "newdomain.com";
- set req.backend_hint = newdomain;
- }
- else {
- return (pass);
- }
- if (req.method == "PURGE") {
- if (client.ip !~ purge) {
- return (synth(405));
- }
- if (req.http.X-Purge-Method == "regex") {
- ban("req.url ~ " + req.url + " && req.http.host ~ " + req.http.host);
- return (synth(200, "Banned."));
- }
- else {
- return (purge);
- }
- }
- #Drop cookies
- set req.http.cookie = regsuball(req.http.cookie, "wp-settings-\d+=[^;]+(; )?", "");
- set req.http.cookie = regsuball(req.http.cookie, "wp-settings-time-\d+=[^;]+(; )?", "");
- set req.http.cookie = regsuball(req.http.cookie, "wordpress_test_cookie=[^;]+(; )?", "");
- if (req.http.cookie == "") {
- unset req.http.cookie;
- }
- #Handle admin login
- if (req.url ~ "wp-admin|wp-login") {
- return (pass);
- }
- }
- sub vcl_backend_response {
- # Happens after we have read the response headers from the backend.
- #
- # Here you clean the response headers, removing silly Set-Cookie headers
- # and other mistakes your backend does.
- }
- sub vcl_deliver {
- # Happens when we have all the pieces we need, and are about to send the
- # response to the client.
- #
- # You can do accounting or modifying the final object here.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement